Image rollover using javascript
Sponsored Links
To facilitate smooth image rollovers in JavaScript, it's recommended that the images are preloaded so that the extra trip to the server is saved when the visitor moves the mouse over the image and the image changes immediately. Preloading is the process by which all images that are to be used for roll-overs are loaded along with the document.
Here is the code:
<script type="text/javascript"> <!-- var image1 = new Image(); image1.src = "moveup.gif"; var image2 = new Image(); image2.src = "movedown.gif"; var image3 = new Image(); image3.src = "an1.gif"; var image4 = new Image(); image4.src = "an2.gif"; //--> </script>
Note: The preloader code should be placed in the HTML head, preferably before any other JavaScript code.
The code above assumes that the images are located in the same directory as the HTML file. If the images are placed in another directory, use relative URLs for the images in the preloader script as well for passing arguments to the rollover function.
Page contents: Details on the popular image rollovers or changing images on mouse over using smart JavaScript code.
Comments, questions, feedback... whatever!
Recent Articles
Recent Blog Posts
Popular Articles
- Hotmail Sign In page
- Create a Hotmail account - Instructions
- Create Gmail address
- Download and install Outlook Express
- Get your free Gmail address
- Outlook Express new version
- Create my own email address
- Browers for Windows list
- Get email address
- Color combinations for web sites and pages
- Create Yahoo ID
More web tips & tricks
- Outlook Express Help - tips & tricks (53)
- Windows Live Mail help and tips (36)
- Windows Mail help (25)
- Hotmail help and tips (42)
- Yahoo help & support (45)
- AOL email help (26)
- Gmail help and tips (36)
- Internet tips & tricks (12)
- Web Design tips & tricks (33)
- HTML, Javascript tips tricks (68)
- Web Promotion tips & tricks (8)
- Graphics tips & tricks (20)
