loadSound();
当有人关闭浏览器时,我想打开一个 jquery 弹出窗口。但它没有打开弹出窗口。
代码工作:
window.onbeforeunload = function() {
alert("hello");
}
代码不起作用:
window.onbeforeunload = function() {
loadSound();
}
不知道为什么它适用alert("hello");
但不适用loadSound();
整个代码:
function lightbox(){
//to adjust popup width adjust here
$.colorbox({inline:true, href:"#inline_content",onClosed: pauseSound, overlayClose: false});
}
function pauseSound() {
document.getElementById("notification_sound").pause();
}
///////////////////pop strts here
function loadSound() {
lightbox();
document.getElementById("notification_sound").play();
}
///////////////popup ends here
window.onbeforeunload = function() {
loadSound();
}