如何在关闭 ParentWindow 中的 PoPupWindow 后显示消息(在倒计时器中间)?

发布于 2024-12-23 12:49:08 字数 2906 浏览 2 评论 0原文

我的主页(Default.aspx)中有两个弹出窗口,如下所示:

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 秒开始)
在此计时器期间,我不想让我的用户关闭弹出窗口。
我该怎么做?


or how can i show a message in parent window when user closes one of popup windows?
mean what is the way to make a connection between closing of popup windows and their parent window?

提前致谢

i have two popup windows in my Home Page (Default.aspx) like below :

apsx Code :

<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 Code :

 <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>

as you see there is a countdown timer in parent window (starts from 60 seconds)
during this timer i do not want to let my users to close popup windows.
how can i do that?


or how can i show a message in parent window when user closes one of popup windows?
mean what is the way to make a connection between closing of popup windows and their parent window?

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

将军与妓 2024-12-30 12:49:08

这样,无论打开的弹出窗口是否关闭,您都可以获得反馈。

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

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

问候

This way you can get feedback whether the opened popup is closed or not.

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

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

Regards

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文