homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
rollover javascript code - efficiency?
scorpion




msg:1493021
 4:35 pm on Mar 19, 2003 (gmt 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?

 

DrDoc




msg:1493022
 9:35 pm on Mar 19, 2003 (gmt 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;
}

bill




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved