HTMLtarget 屬性


<area> 元素的 target 屬性可用於設定連結文件開啟的位置,如新視窗、同一幀、父幀等。

語法如下:

<area target="_blank|_self|_parent|_top| frame">

此處, _blank 用於在新視窗或選項卡中開啟連結文件,_self 在點選該連結時在同一幀中開啟連結文件,_parent 在父幀中開啟文件,_top 在整個視窗主體中開啟連結文件,frame 在指定的幀中開啟連結文件。

我們現在來看一個示例,演示如何實現 <area> 元素的 target 屬性−

示例

 線上演示

<!DOCTYPE html>
<html>
<body>
   <h2>Learning</h2>
   <p>Learn these technologies with ease....</p>
   <img src = /images/usemap.gif alt = "usemap" border = "0" usemap = "#tutorials"/>
   <map name = "tutorials">
      <area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27"
         href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank"/>
      <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial"
         href = "/html/index.htm" target = "_blank" />
      <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial"
       href = "/php/index.htm" target = "_blank" />
   </map>
</body>
</html>

輸出

在以上示例中,我們已設定了下圖的對映−

<img src = /images/usemap.gif alt = "usemap" border = "0" usemap = "#tutorials"/>

現在,我們設定了該圖及其中的區域以實現形狀−

<map name = "tutorials">
<area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27"
href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank"/>
<area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial"
href = "/html/index.htm" target = "_blank" />
<area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial"
href = "/php/index.htm" target = "_blank" />
</map>

上面,我們已將以下內容設定為在新視窗(即 _blank)中開啟連結文件,該視窗或選項卡用於在新視窗或選項卡中開啟連結文件

target = "_blank"

更新日期:29-6 月 2020

148 次瀏覽

助力您的 事業

完成課程獲得認證

開始
廣告