I am currently using the javascript setTimeout function to continuously loop through the same 4 different websites every 10 seconds. I need an accurate way to show a countdown timer of how many seconds are left before the next website is displayed. Is there a way to subtract the time being used in the setTimeout function already being used to create the timer? Here is the current Javascript that I am using:
<script type="text/javascript">
var pages = [
'webpage 1',
'webpage 2',
'webpage 3',
'webpage 4'
], p = pages.length;
while(--p > -1){
(function(p){
var a = document.createElement('a');
a.href = pages[p];
pages[p] = a;
})(p);
}
function loadIframe() {
var page = pages[(p = ++p % pages.length)], bust = 'bustcache=' + new
Date().getTime();
page = page.search? page.href + '&' + bust : page.href + '?' + bust;
document.getElementById('if_one').src = page;
setTimeout(loadIframe, 10000);
}
loadIframe();
</script>