<a>标签作用以及target属性

<a>标签的target属性大致有这几种:

(1)_blank

(2)_self

(3)_parent

(4)_top

------------------------作用1:超链接--------------------------------------------

1、<a href="https://www.baidu.com/" target="_blank">超链接</a>在一个新的窗口打开连接相应的网页。

2、<a href="https://www.baidu.com/" target="_self">超链接</a>在原来的窗口打开连接相应的网页。(如果target属性值不写的话,默认是这种方式)

3、<a href="https://www.baidu.com/" target="_parent">

4、<a href="https://www.baidu.com/" target="_top">

------------------------作用2:锚点--------------------------------------------

<div id="runtop"></div>

通过<a href="#runtop">返回顶部</a>能够实现一个常见的返回顶部的功能。

------------------------作用3:打电话或者发邮件--------------------------------------------

<a href="tel:123456">打电话给号码为123456的人</a>

<a href="mailto:[email protected]">发邮件给给号码为[email protected]的人</a>

------------------------作用4:协议限定符--------------------------------------------

<a href="javascript:alert("强制运行的javascript代码")">这样就能够在<a>标签被点击的时候强制运行href属性里面的代码</a>

猜你喜欢

转载自www.cnblogs.com/wyx221/p/10071254.html