JustGotAQuestion Posted April 6, 2008 Share Posted April 6, 2008 So i was wondering what method, of the two i am about to describe, is the best for making rollovers, and why. 1. This is the way i do it <img src="img.gif" onmouseover="src='img_over.gif'" onmouseout="src='img.gif'" /> 2. This is more complicated, but i'm wondering if its better I can't actually do it, but its the javascript method that dreamweaver does for you. I think it preloads the images and then "swaps" them or something. Please make sure to include why one is better. I like my way because its simple, but is it worse in any way? Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted April 6, 2008 Share Posted April 6, 2008 Why not just use css? No javascript needed for rollovers. If you make it a link it would work in almost all browsers. If you don't have it as a link, it won't work in old browsers like IE6. Quote Link to comment Share on other sites More sharing options...
haku Posted April 7, 2008 Share Posted April 7, 2008 Of those two, the second is most likely better as it pre-loads the images. But neither of them are as good as using CSS like The Film God said. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 7, 2008 Share Posted April 7, 2008 http://www.wellstyled.com/css-nopreload-rollovers.html has a triple state roll-over but you can just use 2 of them as I often do.... Quote Link to comment Share on other sites More sharing options...
haku Posted April 7, 2008 Share Posted April 7, 2008 That's pretty cool, I like it. I will definitely use it. This guy has a good thing going on with his rollovers too. Quote Link to comment Share on other sites More sharing options...
JustGotAQuestion Posted April 24, 2008 Author Share Posted April 24, 2008 Awesome, i didn't even think to use css... Here is what i've found: Pros: Eliminates clutter. Using an external stylesheet, i don't need to confuse myself by looking through lines of rollover code on my main page. Cons: Images take a second to load. Is there a way to preload the images AND use the css method? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 25, 2008 Share Posted April 25, 2008 yes... don't use 2 images - use 1 image as a background and simply move it up/down or left/right on mouse over... Quote Link to comment Share on other sites More sharing options...
haku Posted April 25, 2008 Share Posted April 25, 2008 Javascript takes the same amount of time to load the image (it has to be downloaded one way or another). The method Mr. Mariner posted is the best way to preload your image. Quote Link to comment Share on other sites More sharing options...
JustGotAQuestion Posted April 25, 2008 Author Share Posted April 25, 2008 Oh, wops. I was too quick to shrug off that one image idea...i didn't even think of the benefit. Thats much cleaner! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.