Forum Moderators: open

Message Too Old, No Replies

Rotating page content

perhaps using frames and javascript?

         

seashell

9:40 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



I'm trying to set up a page that will cycle through several html documents, displaying each one for about 10 seconds. I was thinking that the easiest way to do this would be to use a frameset with javascript that changes the src of the frame. I'm haven't had much experience with javascript, so any suggestions would be appreciated.

seashell

10:34 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



I think I got it!

Here's the code I came up with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Rotating Pages</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
function rotate() {
if (currentPage < totalPages) currentPage++;
else currentPage = 1;
parent.rotateFrame.location.href = prefix + currentPage + '.htm';
setTimeout('rotate()', lullTime)
}

var prefix = 'rotate';
var currentPage = 0;
var totalPages = 3;
var lullTime = 10000;
</script>

</head>

<frameset onload="rotate()">
<frame name="rotateFrame" src="rotate1.htm">
</frameset>

</html>

adni18

12:45 am on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you might also want to load all the pages first, then, use the onLoad event to check to make sure all the frames are loaded, then start the cycle, so the browser can show them quick as lightning. :-)

rocknbil

2:50 am on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The timer will vary based on the speed of the processor viewing it.

If it's not an indexed page, you can just use an http-refresh:

<meta http-equiv="refresh" CONTENT="10; url=page_two.html"> ...

<meta http-equiv="refresh" CONTENT="10; url=page_three.html"> ...

<meta http-equiv="refresh" CONTENT="10; url=back_to_page_one.html">

Not recommended for main pages as search engines apparently don't like a lot of redirection.