退出Pop Javascript无法正常运行

时间:2013-03-20 21:30:50

标签: javascript jquery onload onunload

我一直试图让这个退出流行音起作用。到目前为止,我可以在FF,Chrome和Safari的Mac上使用它,但在IE,FF,Chrome for Windows上苦苦挣扎。这是我到目前为止尝试过的两个片段:

<script language=javascript>
function thankYou(){
var win=window.open("[url.com]", "_blank", "left=20,top=20,width=500,height=500,scrollbars=1"); win.focus();  }
</script>

<body onUnload="thankYou()">

<SCRIPT>
function thankYou() {

var ConfirmStatus = confirm("We would love to receive your feedback on your experience of this page. Would you like to complete our short survey?");

if (ConfirmStatus == true) {
window.open("[url]", "win", "left=20,top=20,width=500,height=500,scrollbars=1");
} else {
window.close();
}

}

window.onunload=thankYou;
</SCRIPT>

不确定如何在Windows上运行它。提前谢谢!

1 个答案:

答案 0 :(得分:1)

变化:

<body onUnload="thankYou()">

为:

<body onBeforeUnload="thankYou()">

和....

变化:

window.onunload=thankYou;

为:

window.onbeforeunload=thankYou;