UniqueData
asked on
cycle through html pages
I stumbled upon the following code which is almost exactly what I am looking for. Except, instead of having links for each page at the top, how can the code be changed to have Forward/Backward links instead?
<html>
<style type="text/css">
#pagination a {
padding-right: 1em;
}
</style>
<div id="pagination"></div>
<iframe id="if_one" src="" style="width: 2500px;height: 2000px;float: left;margin: 20px;"></iframe>
<script type="text/javascript">
var pages = [
'CyclePage1.html',
'CyclePage2.html',
'CyclePage3.html'
], p = pages.length, paginate = document.getElementById('pagination'), thepage;
while(--p > -1){
(function(p){
var a = document.createElement('a');
a.href = pages[p];
a.appendChild(document.createTextNode('Page ' + (p + 1)));
a.onclick = function(){
var bust = this.search? '&' : '?';
bust += 'bustcache=' + new Date().getTime();
window.frames[0].location.href = this.href + bust;
thepage = this;
return false;
};
paginate.insertBefore(a, paginate.firstChild);
pages[p] = a;
})(p);
}
thepage = pages[0];
function loadIframe() {
thepage.onclick.apply(thepage);
setTimeout(loadIframe, 120000);
}
loadIframe();
</script>
</html>
ASKER
Thank you much. Only one problem. on load I would like the first page in the array to be loaded, but I don't want to hard code in the src of the frame. Is there a way on load to get the first one loaded?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome. Thanks
Open in new window
You will need to change the web addresses in the array to pages that exist on your server