在页面<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