Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript退出弹出函数不支持';在镀铬和IE中不能正常工作_Javascript_Jquery_Redirect - Fatal编程技术网

JavaScript退出弹出函数不支持';在镀铬和IE中不能正常工作

JavaScript退出弹出函数不支持';在镀铬和IE中不能正常工作,javascript,jquery,redirect,Javascript,Jquery,Redirect,我有一个exit popup js函数,当有人试图离开页面时,它会显示一个警报并向url添加一些内容(和重定向) 警报将显示在所有浏览器中,但代码除外: window.location.href = "?p=exit" 不在Chrome和IE中执行 它在Firefox中运行良好。重新加载页面时,将显示一条警报并修改url 看看源代码,它很简单 代码: var exit=true; 函数confirmExit() { 如果(退出) { window.location.href=“?p=exi

我有一个exit popup js函数,当有人试图离开页面时,它会显示一个警报并向url添加一些内容(和重定向)

警报将显示在所有浏览器中,但代码除外:

window.location.href = "?p=exit" 
不在Chrome和IE中执行

它在Firefox中运行良好。重新加载页面时,将显示一条警报并修改url

看看源代码,它很简单

代码:


var exit=true;
函数confirmExit()
{
如果(退出)
{
window.location.href=“?p=exit”;
}
如果(退出)
return“请稍候!不要空手而归!\n\n感谢您抽出时间查看我们的优惠!出发前,我们会免费为您提供一次帮助,以帮助您成功。如果您感兴趣,请单击“取消”或“停留在此页面”按钮!”;
}
  • 无法(跨浏览器)从“onbeforeunload”重定向
  • Chrome阻止在“onbeforeunload”中设置的警报
查看此答案以了解更多信息:

请不要在帖子中使用签名或标语,否则它们将被删除。您能在问题中粘贴一些相关代码吗?此链接不提供此上下文中的任何有用信息。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript">
var exit=true;
    function confirmExit()
            {
            if(exit)
            {
            window.location.href = "?p=exit";
            }
            if(exit)
            return "Wait! Don't Leave Empty Handed!\n\nThank you for taking the time to check out our offer! Before you go we have a complimentary crash to help you succeed. Click the 'Cancel' or 'Stay On This Page' button if you're interested!";
            }
</script>
</head>
<body  onbeforeunload="return confirmExit()">
</body>
</html>