Introduction:-
In this tutorial I will show you how to change the image when the user puts the cursor over an image and then change it back when the user puts the cursor away from the image.
Solution:-
Make These Two Functions Between The <head> tags:-
And Make This code between the <body> Tags:-Code:<SCRIPT language="JavaScript"> if (document.images) { img1on= new Image(100,100); img1on.src="img2.jpg"; img1off= new Image(100,100); img1off.src="img1.jpg"; } function change(imgName) { if (document.images) { imgOn=eval(imgName + "on.src"); document[imgName].src= imgOn; } } function changeback(imgName) { if (document.images) { imgOff=eval(imgName + "off.src"); document[imgName].src= imgOff; } } </SCRIPT>
Save your work and add these 2 images into your directory to see the effectCode:<A onMouseover="change('img1')" onMouseout="changeback('img1')"> <IMG SRC="img1.jpg" name="img1" width="100" height="100"></A>
Explanation:-
You think it is needed? I think its self explanatory. But if you have any problems.. just ask![]()
A Preview:-
Conclusion:-
As Always Feedback is welcome and the full source is attached!!


LinkBack URL
About LinkBacks







Reply With Quote






Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum