I have problem with reloading a list of sites in infinite loop. When in first time I tried do it without iframe, the first site was loaded and nothing else happend. I want to reload some sites from list into iframe. There should be no buttons to reload site, it should be automatic -> show site, wait 20 sec, show site2, wait 60 sec... I want to have different delays, so thats way there is a sleep in infinite loop. In this point I stucked :) Below is my (rubbish :) ) example I tried to run. Any ideas how to do it easy and small as possible ?
<html>
<head>
<script language="JavaScript" type = "text/javascript">
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
function changeSites() {
while(true){
document.getElementById('myFrame').setAttribute('src', "http://www.google.com/");
sleep(4000);
document.getElementById('myFrame').setAttribute('src', "http://www.yahoo.com/");
sleep(2000);
document.getElementById('myFrame').setAttribute('src', "http://stackoverflow.com/");
sleep(5000);
}
}
</script>
</head>
<body>
<iframe id="myFrame" width=100% height=100% >
<p>Your browser does not support iframes.</p>
</iframe>
<script language="JavaScript" type = "text/javascript">
changeSites();
</script>
</body>
</html>