View Single Post
  #1 (permalink)  
Old 12-03-2006, 12:20 PM
TcM's Avatar   
TcM TcM is offline
Moderator
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 8,320
Credits: 0
Rep Power: 74
TcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud of
Default JavaScript:Tutorial, MouseOver Image Change

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:-

Code:
<SCRIPT language="JavaScript">

if (do***ent.images)
 {
     img1on= new Image(100,100);
     img1on.src="img2.jpg";  

     img1off= new Image(100,100);
     img1off.src="img1.jpg";
 }

function change(imgName)
 {
   if (do***ent.images)
      {
         imgOn=eval(imgName + "on.src");
         do***ent[imgName].src= imgOn;
      }
 }

function changeback(imgName)
 {
   if (do***ent.images)
      {
        imgOff=eval(imgName + "off.src");
        do***ent[imgName].src= imgOff;
      }
 }

</SCRIPT>
And Make This code between the <body> Tags:-

Code:
<A onMouseover="change('img1')" onMouseout="changeback('img1')">
<IMG SRC="img1.jpg" name="img1" width="100" height="100"></A>
Save your work and add these 2 images into your directory to see the effect




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!!
Attached Files To view attachments in this forum your post count must be 1 or greater. You currently have 0 posts.

Last edited by TcM; 12-03-2006 at 12:30 PM.
Reply With Quote

Sponsored Links