使用响应重定向退出弹出窗口

Exit Popup With Respone Redirect

本文关键字:窗口 退出 重定向 响应      更新时间:2023-09-26

我需要在我们的一个处理页面上显示退出弹出窗口。我通过注册客户端 javascript 来显示退出弹出窗口,例如

window.onbeforeunload = ShowExitPopUp();

如果您关闭窗口或尝试键入其他 URL,弹出窗口将执行正常。但是,问题是,一旦该过程完成,我的处理页面也会在服务器端执行"响应.重定向"。当响应重定向发生时,退出弹出窗口也会显示出来。在这种情况下,有没有办法让退出弹出窗口不显示?

这是我在下面使用的代码

<script type="text/javascript"> 
window.fbAsyncInit = function() {
    FB.Event.subscribe('comment.create',
    function (response) {
        window.location = "http://domain.com";
    });
    FB.Event.subscribe('comments.remove',
    function (response) {
        window.location = "http://domain.com";
    });   
};
(function() {
    var e = document.createElement('script');
    e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());
//]]>
</script>

<script type="text/javascript">
var ShowExitPopup = true;
function ExitPage()
{
if (ShowExitPopup) 
{ 
ShowExitPopup = false;
location.href = "http://www.YOURURL.com/destination";
return '****************************************'n'YOUR HEADLINE'n'n YOUR TEXT1 'n'n  YOUR TEXT "'n'n                                                                                                     | |'n                                                                                                     | |'n                                                                                                    V V'n                                                      96+                                                v'n  ********************************************************'n';
}
} 
</script>
if (document.getElementById('<%=Panel.ClientID %>').style.display == "") {
$find("<%= Popup.ClientID %>").hide();
document.getElementById("<%= btncloseAcc.ClientID %>").click();
}

试试这个。