浏览器里能调用Window里的命令的

解决方案 »

  1.   

    <html>
    <head>
    <title>无标题文档</title>
    <script language="javascript">
    var mytimer;
    function startload()
    {mytimer=setInterval("alert('时间很晚了,该离开了')",10000);}
    function stop()
    {clearInterval(mytimer);
     con=confirm("真的想结束浏览吗?");
     if(con==true) window.close();
    }
    </script>
    </head><body >
    <input type="button" value="调用startload" onclick="startload()" />
    <center>
    <h3>请在10秒内单击以下按钮以结束你的浏览:</h3>
    <input type="button" value="请在10秒内决定是否单击此按钮" onclick="stop()" />
    </center>
    </body>
    </html>
      

  2.   

    {mytimer=window.setInterval("alert('时间很晚了,该离开了')",10000);}掉了个括号
    定义一个全局变量 var mytimer;