网络编程 
首页 > 网络编程 > 浏览文章

JS定时关闭窗口的实例

(编辑:jimmy 日期: 2025/12/26 浏览:3 次 )
复制代码 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type ="text/css" >
    .main{ background-color:Silver; width :200px; height :100px; margin-left:40%; margin-top :200px; text-align :center;}
    </style>
    <script src="/UploadFiles/2021-04-02/jquery-1.7.1.min.js">    <script language="javascript" type="text/javascript">
        var n = 3;
        function showTime() {
            n--;
            $('#divMain').html(n + ' 秒后关闭窗口');
            if (n == 0)
                window.close();
            else
                setTimeout('showTime()', 1000);
        }
    </script>
</head>
<body onload ="showTime()">
    <form id="form1" runat="server">
    <div id ="divMain" class ="main" >

    </div>
    </form>
</body>
</html>
上一篇:JS中的prototype与面向对象的实例讲解
下一篇:jquery自定义属性(类型/属性值)
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap