<script language="javascript">
//跳到新窗口
function externallinks() {
if (!document.getElementsByTagName) return
var anchors = document.getElementsByTagName_r("a")
for (var i=0i<anchors.lengthi++) {
var anchor = anchors[i]
if (anchor.getAttribute("href"))
anchor.target = "_blank"
}
}
window.onload = externallinks
</script>
2、超链接,一部分在本窗口打开,大部分在新窗口打开
只要在超链接那设置target="_self",并改为如下:
<script language="javascript">
function externallinks() {
if (!document.getElementsByTagName) return
var anchors = document.getElementsByTagName_r("a")
for (var i=0i<anchors.lengthi++) {
var anchor = anchors[i]
if (anchor.getAttribute("target")!='_self')
anchor.target = "_blank"
}
}
window.onload = externallinks
</script>
3、这是用jquery,让其所有超链接在新窗口打开
<script type="text/javascript" src="JQuery/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").attr("target","_blank")
})
</script>
4、用jquery,想让一部分超链接在新窗口打开,只要在基范围加个id就好了,比如,<div id="ccc"><a href="index.html">首页</a></div>
<script type="text/javascript" src="JQuery/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("div#ccc a").attr("target","_blank")
})
</script>
js是做不到的,可以考虑用div来实现,比如说象baidu的登陆(右上角),点一下就弹出个层,只要设置setTimeout(function(){divx.style.visibility='hidden'/*把某个层设为隐藏*/},5555/*超时为5秒左右*/)就实现了按钮添加:onclick="ClosedWindow()"function ClosedWindow()
{
window.parent.window .location .reload()
window.close ()
}