我创作了一个小动画故事。问题是,有时第一个fadein并不会发射。这似乎只是偶尔发生,在某些情况下,我似乎无法弄明白。据我所知,它与缓存有关。
以下是经常遇到问题的网页的代码:
//waits until document is open
$(window).load(function() {
//if it's night time when you read this it displays a night time photo, if it's day time it's a day time photo... don't know how many people might notice
if (time === "night"){
$.backstretch("downtownnight.jpg");
//makes the font white with a black outline so you can read it easily on the night photo
$("#content").css("color","#FFFFFF");
$("#content").css("text-shadow","1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000");
}
else {
$.backstretch("downtownday.jpg");
$("#content").css("text-shadow","1px 0 0 #fff, 0 -1px 0 #fff, 0 1px 0 #fff, -1px 0 0 #fff"); }
});
$(document).ready(function(){
//fades in the first line of text
$("#partFive").fadeIn(2000)
setTimeout(function () {
//fades in the second line of text
$("#partFive").fadeOut(2000)
setTimeout(function () {
$("#awesome").fadeIn(3000)
setTimeout(function () {
$("#awesome").fadeOut(2000)
setTimeout(function () {
$("#awesome").fadeOut(1000)
setTimeout(function () {
$("#partSix").fadeIn(2000)
}, 2000);
}, 2000);
}, 2000);
}, 2000);
}, 2000);
});
我在堆栈溢出时发现了这个以阻止缓存问题,但它似乎没有帮助
<!-- ignores any cache you might have! -->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
您可以在此处找到该网站的测试版本:http://www.chilltoday.com/test/
请求HTML,这是在pastebin:http://pastebin.com/XyM9si2c
答案 0 :(得分:-1)
如果你想要fadeIn效果,你需要确保在调用fadeIn()之前隐藏#partFive。
我认为您的代码没有任何问题。但相反,我添加了“display:none;”对于你需要fadeIn()的所有div,它似乎对我有效。
#partFive, #awesome, #partSix {
display: none;
}