如何在ParentWindow中关闭PoPupWindow后显示消息(在CountDown Timer的中间)?
问题描述:
我在我的主页(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秒开始)
在这个计时器期间,我不想让我的用户关闭弹出窗口。
我该怎么做?
或者当用户关闭某个弹出窗口时,如何在父窗口中显示消息?
这意味着在关闭弹出窗口和其父窗口之间建立连接的方式是什么?
在此先感谢
答
这种方式打开弹出是否关闭与否,你可以得到反馈。
var popup = window.open('http://www.google.com');
var timer = setInterval(function() {
if (popup.closed) {
alert('popup closed!');
clearInterval(timer);
}
}, 500);
问候