Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Tutorials > Javascript

Javascript Javascript Tutorials and Code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-2006, 12:20 PM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Posts: 9,840
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
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 (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>
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..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-18-2007, 08:56 PM
Newbie
 
Join Date: Feb 2007
Posts: 5
Rep Power: 0
sahar88 is an unknown quantity at this point
Default

it's cool ... thank you...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-30-2007, 01:51 PM
Newbie
 
Join Date: Oct 2007
Posts: 2
Rep Power: 0
cvirus is an unknown quantity at this point
Thumbs up Very Good

Very good tutorial, nice for a web site.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-05-2009, 02:36 AM
cryptokyle's Avatar   
Newbie
 
Join Date: May 2009
Location: Singapore
Posts: 11
Rep Power: 0
cryptokyle is an unknown quantity at this point
Send a message via MSN to cryptokyle
Default Re: JavaScript:Tutorial, MouseOver Image Change

Code:
if (document.images)
 {
     img1on= new Image(100,100);
     img1on.src="img2.jpg";  

     img1off= new Image(100,100);
     img1off.src="img1.jpg";
 }
i need help with understanding this portion of the code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-06-2009, 08:49 AM
Jordan's Avatar   
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 18,370
Blog Entries: 90
Rep Power: 20
Jordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of light
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Default Re: JavaScript:Tutorial, MouseOver Image Change

It is creating a new image that is 100x100 (size) and the src is img2.jpg. Similar to saying:

HTML Code:
<img src="img2.jpg" width="100" height="100">
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the hostname in Windows XP navghost General Programming 5 06-03-2009 11:22 PM
How to make image straight - Photoshop ahsan16 Photoshop Tutorials 56 07-30-2008 03:11 PM
Resize Images And Maintain Original Sharpness AfTriX Photoshop Tutorials 7 04-20-2007 09:55 AM
Using change management Cosmet General Programming 2 10-30-2006 06:16 PM
Change design to make more $ Montecarlo Website Design 11 07-13-2006 12:05 PM


All times are GMT -5. The time now is 03:29 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 56%, 75%

Ads