PDA

View Full Version : Javascript vs. CSS for rollovers



gobayview
04-24-2005, 09:28 PM
Hello All:

Is there any benefit to using javascript vs. css in creating image rollovers. I'm familiar with the benefits of CSS, and would think that would be the preferable approach. I know there are scripts that perform special functions, like fade in/out, but for the run of the mill rollovers, why opt for the many javascripts out there?

Any feedback?

Spice

mwinter
04-24-2005, 10:37 PM
Is there any benefit to using javascript vs. css in creating image rollovers.It should depend on the type of rollover, and what is triggering that rollover. If you really want a CSS rollover effect to work in IE, then obviously you're limited to involving a elements due to IE's poor CSS support. Though scripting doesn't suffer from the problem, users do disable client-side scripting so you're still not likely to achieve complete success.

It also depends on what exactly the effect is. If you're being kind to your users and displaying marked-up text with a changing background image, or perhaps just colour changes, a couple of simple rules with well-structured documents could apply the effect to an entire site with minimal overhead. However, if you're using text-containing images or icons, you have little option than to use a scripted solution: the images should be img elements so you can specify alternative text, and only a script could modify the source of that element.


for the run of the mill rollovers, why opt for the many javascripts out there?CSS is still a mystery to many amateur authors, and probably some "professionals", too. They'll also like to use pre-built solutions like Macromedia's, despite being badly implemented and difficult to maintain.

Mike