离开url时淡出页面(以及登录时淡入页面)

Fade page out on leaving url (as well as in on landing)

本文关键字:登录 淡入 url 离开 淡出      更新时间:2023-10-19

我在这里看到了这种效果-页面在加载时淡入,在链接时淡出。。。我找到了代码剪辑来做这件事。

到目前为止我拥有的代码:

$(document).ready(function() {
// the body is already set to display none!
$("body").delay(500).fadeIn(500);
$("a").click(function(event){
    event.preventDefault();
    linkLocation = this.href;
    $("body").fadeOut(500, redirectPage);       
});
function redirectPage() {
    window.location = linkLocation;
}
});

但我不能弄清楚的是,当你在上面的OneUp主题示例中刷新页面时,页面是如何淡出和重新进入的???

可能是ajax??

查看

http://api.jquery.com/unload/

我想这可能就是你想要的。只需制作一个淡出页面的函数,就可以在有人点击或刷新时调用它。

这是正确的答案。。。转到链接,刷新整个页面。看课文。

http://jsfiddle.net/xom89ne6/2/

body{
display: none;
}
$(function(){
    $("body").delay(500).fadeIn(1000);
    $(window).on('beforeunload', function(){
        $("body").fadeOut(1000);
    });
});