![]() |
![]() |
Here is the script that makes it work
The script is in two parts. The first part is in the <head> of the document. The second part is in the <body>
The script that provides the browser with the instructions that allow it to pre-load the images, order the rotation, and set the timing is in the <head> of the document.
- <script language=javascript type="text/javascript">
<!-- Hide script from old browsersadImages = new Array (
- "image1.gif",
"image2.gif",
"image3.gif",
"image4.gif"
)- thisAd=0
imgCt = adImages.length
function rotate() {
- if (document.images) {
thisAd++
if (thisAd == imgCt) {
}
- thisAd = 0
document.adBanner.src=adImages[thisAd]
setTimeout("rotate()", 3 * 1000)
}- } //End hiding script from old browsers -->
</script>
Here's what appears in the <body> tag to set the rotation in motion:
Here's what appears in the <body> of the document:
Here are the images
You can download these to make your own rotating image banner:
![]() |
![]() |
![]() |
![]() |
If you decide to make your own images, a hint is to make them all the same size. That way there will be no distortion or loss of resolution when the images rotate
Return to Javascript for home use.
| Page by Howard Rosenbaum | |
| Find me at hrosenba@indiana.edu | http://www.slis.indiana.edu/hrosenba/www/Demo/rotating.html |