• js 倒计时关闭窗口并刷新父窗口


    父窗口代码:

    Code
    子窗口代码:

    <!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>
    </head>
    <script language="JavaScript" type="text/javascript"> 
    <!-- 
    function refreshParent() 

        window.opener.location.href 
    = window.opener.location.href; 
        
    if (window.opener.progressWindow) 
        { 
            window.opener.progressWindow.close(); 
        } 
        window.close(); 

    //--> 
    </script> 
    <%--<script language="JavaScript">
     var TotalMinutes 
    = 5;
     var TotalMilliSeconds 
    = 5*60*1000;
        
     
    function takeCount()
     {
        
    //计数减一
        TotalMilliSeconds 
    -= 1000;
        
    //计算时分秒
        var hours 
    = Math.floor( TotalMilliSeconds / ( 1000 * 60 * 60 )) % 24;
        var minutes 
    = Math.floor(TotalMilliSeconds / (1000 * 60)) % 60;
        var seconds 
    = Math.floor(TotalMilliSeconds / 1000) % 60;
        
    //将时分秒插入到html中
        document.getElementById(
    "RemainH").innerHTML = hours;
        document.getElementById(
    "RemainM").innerHTML = minutes;
        document.getElementById(
    "RemainS").innerHTML = seconds;  
        
        
    if
     }
     
     window.onload 
    = setInterval("takeCount();",1000);
    </script>--%>
    <script type="text/javascript">
    //<![CDATA[
        var go=5000;
        
    var timer=null;
        
    var endTime = new Date().getTime() + go ;
        
    function interval()
        {
            
    var n=Math.floor((endTime-new Date().getTime())/1000)%60;
            if(n<0return;
            document.getElementById(
    "jumpTo").innerHTML = n;
            setTimeout(interval, 
    10);
        }
        window.onload
    =function(){
            timer
    =setTimeout('refreshParent()', go);
            interval();
        }
    //]]>
    </script>
    <body>
        
    <form id="form1" runat="server">
       
    <div>
        
    <%--<div id="CountMsg">
        倒计时还有:
        
    <strong id="RemainD"></strong><strong id="RemainH">XX</strong>
        
    <strong id="RemainM">XX</strong>
        
    <strong id="RemainS">XX</strong>
        
    </div>--%>
        
        
    <span id="jumpTo">5</span> 秒后 将自动</span>跳转到
        
    <href="javascript:void(0)" onclick="refreshParent()">刷新父窗口并关闭当前窗口</a><br /><br />
        
    <href="sun2.aspx" >去支付</a> 
        
    </div>
        
    </form>
    </body>
    </html>
  • 相关阅读:
    【NOIP】提高组2015 运输计划
    【BZOJ】1635: [Usaco2007 Jan]Tallest Cow 最高的牛
    【51nod】1766 树上的最远点对
    【BZOJ】2054: 疯狂的馒头
    【SRM20】数学场
    【Luogu】P3930 SAC E#1
    【Luogu】P3927 SAC E#1
    【Luogu】 P3928 SAC E#1
    【Codeforces】868C. Qualification Rounds
    【CodeForces】866D. Buy Low Sell High
  • 原文地址:https://www.cnblogs.com/jinweida/p/1375705.html
Copyright © 2020-2023  润新知