當我嘗試關閉頁面或選項卡時,我想打開一個彈出窗口,但沒有關閉它的選項。關閉瀏覽器時打開自定義彈出窗口
我正在使用這個腳本,但它不工作。
<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