因此,我几乎完成了我要实现的目标-全屏欢迎图像,该图像在每次会话加载时显示,并在较大的屏幕上逐渐消失。
它还会在显示期间删除滚动条,并在完成后重新启用。
问题是,当它淡出时,将加载或重新加载任何文本和背景色。图像和定位已经加载/淡入淡出。
任何建议/想法,不胜感激。
我尝试删除css / html,因此让我相信它与javascript有关。
if ($(window).width() > 769) {
$(window).load(function() {
var isshow = sessionStorage.getItem('isshow');
if (isshow== null) {
sessionStorage.setItem('isshow', 1);
document.documentElement.style.overflow = 'hidden'; // firefox, chrome
document.body.scroll = "no"; // ie only
// Show popup here
$.when($('#jPopup').show().delay(4000).fadeOut(2000))
.done(function() {
document.documentElement.style.overflow = 'auto'; // firefox, chrome
document.body.scroll = "yes"; // ie only
});
}
});
}
我也尝试过
$(document).ready
而不是window.load
等。 最佳答案
您可以使用fadeOut本身传递完成回调。
if ($(window).width() > 769) {
$(document).ready(function() {
var isshow = sessionStorage.getItem('isshow');
if (isshow == null) {
sessionStorage.setItem('isshow', 1);
document.documentElement.style.overflow = 'hidden'; // firefox, chrome
document.body.scroll = "no"; // ie only
$("#jPopup").show().delay(4000).fadeOut(2000, function() {
// will run upon fadeout completion
document.documentElement.style.overflow = 'auto'; // firefox, chrome
document.body.scroll = "yes"; // ie only
});
}
});
}
在此处检查工作样本:http://jsbin.com/liruxilupa