我有一个随机的URL加载脚本,但我需要将其更改为有序,因此每个链接按顺序访问(因为它在加载时旋转),然后返回到第一个并再次启动。 任何帮助将不胜感激,特别是因为javascript对我来说就像一个外语。
代码:
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
//Specify IFRAME display attributes
var iframeprops='width=100% height=100% marginwidth="0" marginheight="0" hspace="0 vspace="0" frameborder="0" scrolling="yes"'
//Specify random URLs to display inside iframe
var randomcontent=new Array()
randomcontent[0]="slots/001/index.php"
randomcontent[1]="slots/002/index.php"
randomcontent[2]="slots/003/index.php"
randomcontent[3]="slots/004/index.php"
//No need to edit after here
if (ie||dom)
document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')
function random_iframe(){
if (ie||dom){
var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
}
}
window.onload=random_iframe
</script>