Welcome to WebmasterWorld Guest from 54.227.1.130

Forum Moderators: open

Message Too Old, No Replies

rollover javascript code - efficiency?

     

scorpion

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

10+ Year Member



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?

DrDoc

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

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



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;
}

bill

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

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



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

Featured Threads

Hot Threads This Week

Hot Threads This Month