<html>
<head>
<title>a</title>
<script>
function confirmWindow()
{
 return window.confirm("你确定要打开此窗口吗?");
}
</script>
</head><body>
<a href="b.html" onClick="return confirmWindow()">打开窗口</a>
</body>
</html>
在我的机子上,点取消后还会打开链接,而在我们学校的机房里却不会,为什么?

解决方案 »

  1.   

    <html > 
    <head > 
    <title >a </title > 
    <script > 
    function confirmWindow() 

      if(window.confirm("你确定要打开此窗口吗?"))
       {
         document.location.href='b.html'
       }
     return 

    </script > 
    </head > <body > 
    <a href="#" onClick="confirmWindow()" >打开窗口 </a > 
    </body > 
    </html >
      

  2.   

    多了个return
    <html > 
    <head > 
    <title >a </title > 
    <script > 
    function confirmWindow() 

      if(window.confirm("你确定要打开此窗口吗?"))
       {
         document.location.href='b.html'
       }

    </script > 
    </head > <body > 
    <a href="#" onClick="confirmWindow()" >打开窗口 </a > 
    </body > 
    </html >