<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript">
     function fun()
     {
        setTimeOut('window.close()',2000);
     }
    </script>
</head>
<body text="#00000">
    <form id="form1" runat="server">
    <div>
      <input id="Button" type="button" value="2秒后自动关闭" onclick="javascript:fun()"/>
    </form>
</body>
</html>
上面是在asp.net中编写的js脚本但是怎么setTimeout()没起作用呢,望能帮助一下。

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server"> 
        <title>无标题页 </title> 
        <script type="text/javascript"> 
        function fun() 
        { 
            setTimeout(function(){window.close()},2000); 
        } 
        </script> 
    </head> 
    <body text="#00000"> 
        <form id="form1" runat="server"> 
        <div> 
          <input id="Button" type="button" value="2秒后自动关闭" onclick="fun()"/> 
        </form> 
    </body> 
    </html> 
      

  2.   

    setTimeOut
    ===>
    setTimeout
    (拼写)