Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

rollover javascript code - efficiency?

4:35 pm on Mar 19, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 15, 2002
votes: 0

I like the code that fireworks mx generates for rollovers, preloading the images, etc..

My question is I got a file that looks like this:

"if (document.images) {

image1on = new Image();
image1on.src = "graphics/contents/01hi.gif";

image2on = new Image();
image2on.src = "graphics/contents/02hi.gif";, etc.."

and a changeImages() function.

I'm not sure which software autogenerated this, but my question is which is the best code to use and if it is possible to convert from one rollover code to another automatically...

The above code I found in this file of mine there are so many rollovers, the javascript takes up like 25% of the top of the file! This can't be good for search engines can it?

9:35 pm on Mar 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
votes: 0

Well, you can always dump the script and use CSS instead ;)

Either way, rollover code for different images will be huge...

You can always use external JS/CSS if you're worried abotu Search Engines.

If possible, just use two images - no text - and change the background and text color using CSS.

That's like ... 4 lines of code ;)

a:link {
background: url(img/button_normal.gif);
color: #00f;
a:hover {
background: url(img/button_hover.gif);
color: #f00;

5:20 am on Mar 20, 2003 (gmt 0)

Administrator from JP 

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 12, 2000
votes: 49

tedster's Bare-bones rollover [webmasterworld.com] thread has some good ideas on trimming your code.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members