退出流量代码不起作用

时间:2014-01-05 08:40:21

标签: javascript jquery

我将此代码用于退出流量

<script type=”text/javascript” language=”javascript”>
    function areYouSure() {
    areYouReallySure = true;
    location.href=”http://example.com”
    return “WAIT! Maybe you’d like to try ShamWow instead?\r\nOrder now and we’ll have Chuck Norris personally deliver it!”;

}
window.onbeforeunload = areYouSure;
</script> 

根本不会调用代码。

这是一个演示http://provendate.com/testpop.php

为什么?

1 个答案:

答案 0 :(得分:0)

如果您想在有人离开页面时显示确认信息,您只需要:

window.onbeforeunload = function() {
    return "I'm a really annoying message, please stay !";
}

Here是一个小提琴