Jump to content

Sample javascript for image rollover effect?


addeacher

Recommended Posts

The .js file is not all there is to it, there's also the html. Doing a search on google results in plenty of image rollover samples:

 

http://www.google.com/search?client...rollover&btnG=Google+Search

 

see that already, didn't work for me.

 

I looked at 2 of the very first results, and both offered very simple versions of javascript rollovers. I've used similar ones before - but try to avoid javascript whenever possible now for compatibility issues.

 

These codes all go in your HTML file, these examples do not require a separate .js to run. Also, if you have more than one image you must have unique "name" values for each image.

 

The simplest example would be:

 

  <a href="link.html"
  onMouseOver="document.image1.src='onImage.gif'"
  onMouseOut="document.image1.src='outImage.gif'">
  [img=outImage.gif]

 

Of course, you would need to change the link.html, onImage.gif, and outImage.gif to your filenames. And when adding additional images, update all occurrences of image1 to a new unique value, such as image2, image3, etc.

 

Really though, spend more time searching Google and other html/webdesign sites for answers to stuff like this. If you had, you would have found your answer hours ago and already be working on your next hurdle. :)

Link to comment
Share on other sites

Thanks a lot for all the help and support guys it was a experience for me with the programing, at first we thought about letting the designer that did our site do this but then we thought let whmcs do it but after thought maybe i should give it a shot, if i fail then we will let whmcs do it, so far so good i was able to find a nice script.js that did it more than nice enough, now no more iframe so no more reloading everytime going to different page.

 

Just a few questions though, which is better css or java?

 

and why not to use java if its a simple rollover.

 

Thanks again guys much appreciated.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated