<SCRIPT LANGUAGE=javascript>
<!--
var closeTime=new Date(2002,2,30,2,30)
document.write("<title>",closeTime,"</title>")
closeWin()
function closeWin()
{
MM=new Date()
if(MM>=closeTime)
{
window.close()
}
else{
setTimeout("closeWin()",1000)
 }
}
//-->
</SCRIPT>

解决方案 »

  1.   

    try<html>
    <head>
    <title>Hello World</title>
    <body>
    <input type="button" value="close window" onclick="closeWin()">
    </body>
    <script language="javascript">
    var nSecond = 10;
    var dtStart = null;
    function closeWin()
    {
     var ns = nSecond;
     if (!dtStart)
       dtStart = new Date();
     else
     {
          var dt = new Date();
          var sp = Math.floor((dt.getTime()-dtStart.getTime())/1000);
          if (sp >= nSecond)
          {
    window.opener = null
    window.close();
    return;
          }
          ns= nSecond - sp;
     }
     
     document.title = "Closing in " + ns + " seconds";
     setTimeout("closeWin()",1000);
    }
    </script>
    </html>
      

  2.   

    <script>
    var n=10;
    function clock(){
    if(--n==0){window.opener=null;window.close();}
    document.title="还有"+n+"秒关闭"
    setTimeout(clock,1000);
    }
    clock();
    </script>