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 次浏览

助力您的 事业

完成课程获得认证

开始
广告