如何在每N秒内显示单独的iframe


How to to display separate iframe in every N second?

我读了一些帖子,做了一些研究,然后问,是否有重复的帖子,对不起。

这与这个问题有点相似,但我不希望网页一直循环,我希望网页分别显示在每个iframe中。我想每隔N秒显示一个带有iframe的网站,预期结果就像下面的命令代码一样:

@echo off
echo "Webpage 1"
timeout 5 >nul
echo "Webpage 2"
timeout 3 >nul 
echo "Webpage 3"
timeout 4 >nul

当我尝试使用php时,我使用了以下代码:

<iframe src="http://example.com/page1" width="50%"></iframe> 
<br>
<?php sleep(5); ?>
<iframe src="http://example.com/page2" width="50%"></iframe> 
<br>
<?php sleep(3); ?>
<iframe src="http://example.com/page3" width="50%"></iframe> 
<br>
<?php sleep(4); ?>

如何避免这些页面同时显示?

//need jquery 
urlLists = [ "http://example.com/page1", "http://example.com/page2" ];
key = 0;
//loop
$(document).ready(function()
{
    var refreshId = setInterval( function() 
    {
    if(urlLists[key] == undefined){
     key=0;       
    }
      $('iframe').attr('src',urlLists[key]) ;
    key++;
    }, 5000);
});

//stop at last
$(document).ready(function()
{
    var refreshId = setInterval( function() 
    {
    if(urlLists[key] != undefined){
        $('iframe').attr('src',urlLists[key]) ;
         key++;   
    }else{
window.clearInterval(refreshId );
 }

    }, 5000);
});

在每个页面中只需刷新标题

header('Refresh: 3;url=http://example.com/page1');

当然,将3更改为N.的值