2011-12-29 26 views
0

我在我的主頁(Default.aspx的),如空兩個彈出窗口:如何在ParentWindow中關閉PoPupWindow後顯示消息(在CountDown Timer的中間)?

apsx代碼:

<div id="OffDiv"> 
</div> 
<div id="TimerContainer"> 
    <asp:Image ID="imgWhiteCircle" runat="server" ImageUrl="~/Images/WhiteCircle.png" /> 
    <asp:Label ID="lblCountDown" runat="server" Text="60" Font-Bold="True" Font-Size="50px" 
     ForeColor="Black"></asp:Label> 
</div> 

CSS:

div#OffDiv 
{ 
    display: none; 
    position: fixed; 
    top: 0px; 
    right: 0px; 
    width: 100%; 
    height: 100%; 
    padding: 0px; 
    margin: 0px; 
    z-index: 90000; 
    background-color: black; 
    filter: alpha(opacity=30); /* internet explorer */ 
    -khtml-opacity: 0.3; /* khtml, old safari */ 
    -moz-opacity: 0.3; /* mozilla, netscape */ 
    opacity: 0.3; /* fx, safari, opera */ 
} 
div#TimerContainer 
{ 
    display: none; 
    position: absolute; 
    width: 110px; 
    height: 110px; 
    top: 200px; 
    left: 50%; 
    margin-left: -55px; 
    padding: 0px; 
    z-index: 90001; 
} 
#imgWhiteCircle 
{ 
    width: 110px; 
} 
#lblCountDown 
{ 
    position: absolute; 
    width: 70px; 
    height: 65px; 
    text-align: center; 
    top: 50%; 
    left: 50%; 
    margin-left: -35px; 
    margin-top: -32.5px; 
} 

的JavaScript代碼:

<script language="javascript" type="text/javascript"> 
     $(function() { 
      var x = screen.availWidth; 
      $('div#OffDiv').css({ 'width': x }); 
      var y = screen.availHeight; 
      $('div#OffDiv').css({ 'height': y }); 

      $('div#OffDiv').css({ 'display': 'block' }); 
      $('div#TimerContainer').css({ 'display': 'block' }); 

      window.open('http://www.MyPoPUp1.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false); 
      window.open('http://www.MyPoPUp2.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false); 
      window.focus(); 

      var sec = $('#TimerContainer span').text() 
      var timer = setInterval(function() { 
       $('#TimerContainer span').text(--sec); 
       if (sec == 0) { 
        clearInterval(timer); 
        $('div#OffDiv').css({ 'display': 'none' }); 
        $('div#TimerContainer').css({ 'display': 'none' }); 
       } 
      }, 1000); 
     }); //End Of $(function() 
    </script> 

正如你所見,在父窗口中有一個倒數計時器(從60秒開始)
在這個計時器期間,我不想讓我的用戶關閉彈出窗口。
我該怎麼做?


或者當用戶關閉某個彈出窗口時,如何在父窗口中顯示消息?
這意味着在關閉彈出窗口和其父窗口之間建立連接的方式是什麼?

在此先感謝

回答

1

這種方式打開彈出是否關閉與否,你可以得到反饋。

var popup = window.open('http://www.google.com'); 

    var timer = setInterval(function() { 
     if (popup.closed) { 
      alert('popup closed!'); 
      clearInterval(timer); 
     } 
    }, 500); 

問候

相關問題