求一段实现几个页面在iframe中每隔几秒钟自动跳转
求一段实现几个页面在iframe中每隔几秒钟自动跳转,这样可以显示几个版块最新的内容.
------解决方案-------------------- <html>
<head>
<script>
$ = function (id) {
return document.getElementById(id);
};
var url = [];
url.push ( 'http://www.baidu.com ');
url.push ( 'http://www.google.com ');
url.push ( 'http://www.csdn.cn ');
var count = 0;
function changeSrc (ifr) {
var iframe = $(ifr);
if (count > = url.length) count = 0;
iframe.src = url[count];
count ++;
}
setInterval( "changeSrc( 'iframe1 ') ",3000);
</script>
</head>
<body>
<iframe id= "iframe1 " src= "http://www.baidu.com "> </iframe> </body>
</html>
------解决方案-------------------- <script language= "JavaScript ">
<!--
//设置版块跳转的路径,多个类此
var bq1={ "1.htm ", "2.htm ", "3.htm "};
var bq2={ "11.htm ", "22.htm ", "33.htm "};
var i=j=0;//各个版块的计数变量;
var time=5000;//5秒跳转;
//跳转函数,counter为相应版块的计数变量
function jump(iframeName,bqArr,counter)
{
if(counter <bqArr.length)
{
iframeName.location.href=bq1[i];
counter++;
}
else
{
iframeName.location.href=bq1[0];
counter=0;
}
}
//调用
window.setInterval(jump( "iframe1 ",bq1,i),time);
window.setInterval(jump( "iframe2 ",bq2,j),time);
//-->
</script>