Jump to content

Image Rollover, I am new to JS please explain me something


cs.punk

Recommended Posts

Ok I understand PHP basically...

 

I just want to know if someone can explain this to me:

 

//Preload images

if (document.images) 
{login_on = new image
   login = new image
                                          //what are these 'new image' for? A varible
                                         //assigned to another one? 
   login_on.src = "images/login_on.jpg"
   login.src = "images/login.jpg"
}

function chgImg(imgField,imgState)
{document[imgField].src = "images/" + imgField + imgState + ".jpg"
}

 

Thats the script right,

 

   <a href="login.php"
   onmouseover="chgImg('login','_on')"
   onmouseout="chgImg('login','')">
   <img src="images/login.jpg" width="120" height="62" border="0"name="login" />
   </a>

 

How could I write this script so that I can call on the externel script (the first one) for all my image roll overs, not just for the login button?

 

Link to comment
Share on other sites

Theres a much easier way to do mouseover image changes without javascript.

 

HTML

<td class="nav_01">
<a href="#"><span class="nav-hide">Home</span></a>
</td>

 

CSS

.nav_01 a {
width: 80px;
height: 45px;
background: url(../images/nav_01.png);
background-repeat: no-repeat;
display: block;
margin: 0 auto;
}
.nav_01 a:hover {
background: url(../images/nav_over_01.png);
background-repeat: no-repeat;
}
.nav-hide {
display:none;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.