<html>
<head>
<script language="javascript">
function pop_window(){
if(document.getElementById("text1").value!="close"){
window.open("http://www.csdn.net");
}
}function change(){
document.getElementById("text1").value="close";
}
</script></head>
<body onUnload="pop_window();"><a href="http://www.163.com" onclick="change();">www.163.com</a>
<input type="hidden" value="open" name="text1" id="text1">
</body>
</html>

解决方案 »

  1.   

    谢谢楼上的回答!
    你写的代码,效果是没问题
    但是,要在页面上每个链接都加上 onclick="change();"  
    我的页面里很多连接是和其他页共用的,所以这样也不可取
    有没有更好的方法呢?
    谢谢
      

  2.   

    就是说,我没办法在页面所有的链接中加 onclick="change();"
    但是我又想实现你这个代码的功能,有没有办法修改代码?谢谢!
      

  3.   

    <html>
    <head>
    <script language="javascript">
    function pop_window(){
        if(document.getElementById("text1").value!="close"){
            window.open("http://www.csdn.net");
        }
    }
    document.onclick=function(e)
    {
      e=e||event;
      var tag=e.target?e.target:e.srcElement;
      if(tag.tagName=="A")
        document.getElementById("text1").value="close";
    }
    </script></head>
    <body onUnload="pop_window();">
    <a href="http://www.163.com">www.163.com</a><br/><a href="http://www.163.com">www.163.com</a><br/>
    <a href="http://www.163.com">www.163.com</a><br/><a href="http://www.163.com">www.163.com</a>
    <input type="hidden" value="open" name="text1" id="text1">
    </body>
    </html>