所有链接都设成_blank简单方法

时间:2015/11/10 19:26:00来源:互联网 作者:flyso 点击: 970 次

在页面<head></head>之间加入<base target=_blank>(XHTML:<base target="_blank" />),就会使该页面所有链接均为新开窗口打开。

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>所有链接均为_blank的方法</title>
<base target="_blank" />
</head>

<body>
<p><a href="http://www.sina.com">新浪</a></p>
<p><a href="http://www.163.com">网易</a></p>
<p><a href="http://www.sohu.com">搜狐</a></p>
</body>

<base>是一个链接基准标记,用以改变页面中所有链接标记的参数默认值。

引申应用:

<head><base href="http://blog.hexun.com/dix" target="_blank" /></head>
<body><a href="blog/">月亮光华</a></body>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>所有链接均为_blank的方法</title>
<base target="_blank" /><base href="http://blog.hexun.com/dix" />
</head>

<body><a href="blog/">月亮光华</a></body>

那么不管这个页面放置在任何域下面,该链接都会指向http://blog.hexun.com/dix

Copyright © 2005 - 2016 flyso.cn. 飞搜 版权所有 鄂ICP备11002783号-3