![]() |
Simple Image Rotation in JavaScript
Sometimes, we need to rotate images on ours web pages, it may be ads or some simple images.Below you'll find the code for implementing the same.
You can create as many image rotations you want, you just need to specify the urls of the images in an Array, and the object where the image will be shown. The function RotateImages is called with the Array/Img Object number, and at what index of the array the rotation should start. HTML Code:
<html>Auto Suggest with Javascript Hide/Show and Toggle DIV usng JavaScript Arrays in Java script Sorting A Un-Ordered List (UL) Using JavaScript Timer In JavaScript |
Re: Simple Image Rotation in JavaScript
Well,this is OKay,but could you guide me how to slide the image using java script
|
Re: Simple Image Rotation in JavaScript
Well,this is OKay,but could you guide me how to slide the image using java script
THANK YOU |
Re: Simple Image Rotation in JavaScript
Well, this script rotates the image at a preset timed interval, but for sliding the image, u'll need to change the position of the image using a javascript timer.
u can gradually increase the left css value, then it'll slide from left to right! |
Re: Simple Image Rotation in JavaScript
hi! quick question, i've followed this tutorial and got the images to rotate...
my javascript knowledge is quite weak... i want each image to link to a different page...how would i go about doing this? i know you mention specifying the urls in an array but i have no idea how, as i said my javascript knowledge is weak.. Thanks in advance! |
Re: Simple Image Rotation in JavaScript
You'll need to create a two-dimensional array in this case! Try it out and keep us posted with code snippets.
|
Re: Simple Image Rotation in JavaScript
I like simplicity, especially with code. After wasting hours trying to tweak a flashy image rotation Javascript, complete with .js files to include, I gave up, called up the Google, and found this wonderfully simple code from a throwaway response on an online forum:
Quote:
To specify the images to rotate, just add file path and image names to the var ImageArr1 = new Array(”", “”, “”) line. Be careful to wrap each file path and image name with double quotes with a comma between each and you’ll be fine. The last element to set is the ‘3500′ at the end of the window.setTimeout(..) line. That’s the number of milliseconds between the display of each image. This code does not have fancy wipes, dissolves, or other whizzy features. But it doesn’t require include references to javascript files and other complexity that can go horribly wrong horribly fast. Just tweak this code and drop the Javascript part at the bottom of your web pages or templates (so it doesn’t get in the way of search bots). The image, the “home-photo” div in this example, goes where it goes in your design. |
Re: Simple Image Rotation in JavaScript
Hello friends,
I was quite interesting to view those expert sharing their expertise over here. Please help me to solve my conflict over "rotating image" issue. I have a webpage and the header image was set in my CSS as 'header-bg.jpg'. I would like to add more than 1 image in my header, meaning that the header image will rotate one to another after few seconds. Please help me to work on the right coding. This is my CSS: Code:
/* CSS Document */ |
Re: Simple Image Rotation in JavaScript
i wanna to link every rotating image to sum page..
Can u plz tell me how to go abt 4 dis??? |
Re: Simple Image Rotation in JavaScript
A simplified version with just one set of images...with some URLs attached to the images...The timeout is in miliseconds...3000 = 3 seconds...
Hope this helps... Code:
<body> |
| All times are GMT +5.5. The time now is 12:06. |