[英]Javascript - Load a page 4 times then change on the 5th time
I'm making a rolling screen based in PHP, i use javascript to load a page every 10 seconds. 我正在基于PHP创建滚动屏幕,我使用javascript每10秒加载一次页面。 Here is what I have so far:
这是我到目前为止的内容:
<script>
setInterval(function(){
$('#container').fadeOut('slow').load('screener.php').fadeIn("slow");
},10000);
</script>
so i'm guessing I need a count to load either screener.php or if the count = 5, load alternate.php. 所以我猜我需要一个计数来加载screener.php或如果计数= 5,则加载alternate.php。
Yes, that is exactly what you need to do. 是的,这正是您需要做的。
var counter = 0;
setInterval(function(){
if (counter % 5 === 0) {
$('#container').fadeOut('slow').load('alternate.php').fadeIn("slow");
} else {
$('#container').fadeOut('slow').load('screener.php').fadeIn("slow");
}
counter++;
},10000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.