2009-11-24 37 views

回答

6

我認爲這將是最不突兀的方式。它只是在卸載之前淡出頁面,而不管卸載是由F5引起的,導航到另一個頁面,關閉瀏覽器窗口或單擊鏈接。

window.onbeforeunload = function() { $(document.body).fadeOut() } 

如果你只是希望它的特殊環節,壽,你可以試試這個:

$('a.withFade').live('click', function() { 
    var url = $(this).attr('href'); 
    $(document.body).fadeOut('1000', function() { 
     location.href = url; 
    }); 
    return false; 
}); 
+2

或另外,如果你想的jQuery上下的語法:'$(窗口).bind('beforeunload ',function(){$(document.body).fadeOut();});' –

+0

+1這是一個很好的觀點,這可能會更好的瀏覽器兼容性以及 –