当我尝试关闭页面或选项卡时,我想打开一个弹出窗口,但没有关闭它的选项。关闭浏览器时打开自定义弹出窗口
我正在使用这个脚本,但它不工作。
<script language="JavaScript">
window.onbeforeunload = closepopup;
function closepopup(){
var id = '#dialog';
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(500);
$('#mask').fadeTo("slow",0.9);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/6-$(id).height()/6);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
}
</script>
它怎么不起作用?更加详细一些! – Stibu
除了具体说明它如何工作,#dialog和HTML(简化)的HTML代码片段将会很有帮助。 – Romuloux
请检查此URL http://avirasofttech.com/demo/。您可以检查源代码中的整个代码。当您尝试关闭该页面时,会出现浏览器默认弹出窗口。当你点击留在页面上。我会显示我的弹出窗口。但我不想显示浏览器的默认弹出窗口。它应该直接显示我的弹出窗口。我知道我的解释不好。但是当你检出网址时,你会明白。谢谢 – Asif