【发布时间】:2012-06-26 04:48:49
【问题描述】:
我也不喜欢退出弹出窗口,但我想在即将到来的节日日进行整合,所以要感谢我的访客并给他们一些特别的东西。 我是下面的这段代码,用于在退出时重定向。
var exitPop = false;
var nonFire = false;
window.onbeforeunload = function () {
if(!exitPop){
exitPop=true;
return 'Happy Festival Day!';
}
};
setInterval(function(){
if(exitPop && !nonFire){
nonFire = true;
window.location.href = 'http://google.com';
}
}, 200);
我在下面使用这个代码,它基本上是在做评论时重定向
<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>
我不想将退出重定向显示给发表评论的访问者,因为这让我的访问者很恼火,我希望该代码仅在单击退出时执行。那么我应该包含哪些代码会创建评论重定向异常并且不应该向评论者显示弹出窗口
【问题讨论】:
标签: javascript jquery html redirect