Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rotating webpage content

Status
Not open for further replies.

BowlerBob

Programmer
Jan 16, 2003
21
GB
Hi

I am completely new to XML and XSL.

On my website's homepage ( ), I have a scrolling area known as "Cool Tips" and several Amazon ads.

I would like to rotate the contents of these parts; say once a day or once a week.

Cool Tips content could be held in html files, I think the same could probably be done for the &quot;<a>&quot; tags of the Amazon ads.

If it can be done, would it use Arrays of the content's source files ?

Can anyone point me to examples ?


thanks

BobTheBowler
 
I think you would be best using a javascript snippet unless you specifically want to explore a solution using xml/xsl etc.

here's a snippet of javascript i use to rotate some gifs, but you could adapt it for links, or text etc..


say you have 4 gifs that you want to rotate every 5 seconds:


<script>
var pause = 5000; // 5 second delay in microseconds
var n = 0;
var imgs = new Array (&quot;1.gif&quot;, &quot;2.gif&quot;, &quot;3.gif&quot;,&quot;4.gif&quot;);
var preload = new Array();

for ( var i = 1; i < imgs.length; i++)
{
preload = new Image();
preload.src = imgs;
}

function rotate()
{
document.images.pic.src = imgs[n];
(n == (imgs.length - 1)) ? n = 0 : n++; setTimeout (&quot;rotate()&quot;, pause );
}

window.onload = rotate;

</script>

hope this helps
 
forgaot to include the HTML to include in your htm page:

something like:

<img name = &quot;pic&quot; src =&quot;1.gif&quot; width = &quot;100&quot; height =&quot;100&quot;>

try it out
 
>>> Cool Tips content could be held in html files,

I have managed to work the images with JavaScript.
Changes are done using setInterval()


However, the Cool Tips area contains a lot
of HTML formatting and I can't seem to be able to
swap the different contents with JavaScript.
This area would only change each time the page is viewed.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top