jQuery,FadeIn卸载前 [英] Jquery, FadeIn before unload

查看:73
本文介绍了jQuery,FadeIn卸载前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您愿意,我正在尝试实现过渡效果.在准备好doc的div淡出时,我遇到的问题是,当访问者离开页面(或.unload)时,我希望div淡入.

I'm trying to accomplish a transition effect if you will. On doc ready div fades out, the problem im having is when a visitor navigates away from the page (or .unload) I want the div to fade back in.

$(document).ready(function(){

    $('#overlay').fadeOut(2000, 'easeOutQuad');

});


$(window).beforeunload(function() {

    $('#overlay').fadeIn(2000, 'easeOutQuad');

});

推荐答案

beforeunload事件是不可靠的,您无法确保它们已完全执行,因为不同浏览器和计算机的卸载速度有所不同. 另外,要实现淡入效果,必须延迟卸载,这是不可能的.

beforeunload events are unreliable, you cannot make sure they are fully executed, because the differences in unload speeds across browsers and computers. Also, to achieve the fade-in effect, the unload must be delayed, which is not possible.

这篇关于jQuery,FadeIn卸载前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆