I am using the following script in my header tag to display rotated urls in an iframe but I would like this to be random rather than in a particular order but also retaining the ability to have urls rotated every number of seconds or so like my current script does. If someone could help suggest any modification to the below code to do this then it would be greatly helpful. Thanks.
<script type="text/javascript">
var pages=new Array();
pages[0]="http://www.link1.com";
pages[1]="http://www.link2.com";
pages[2]="http://www.link3.com";
pages[3]="http://www.link4.com";
var i=0;
var time=7000; // this is set in milliseconds
function pageChange() {
document.getElementById("frame").src=pages[i];
i++;
if(i==pages.length) {
i=0;
}
setTimeout("pageChange()",time);
}
onload=pageChange;
</script>



Reply With Quote





Bookmarks