[thelist] Wanted: the definitive fool-proof mouseover JavaScript

Paola Kathuria paola at limitless.co.uk
Wed Jun 27 15:50:00 CDT 2001


.jeff wrote:
> http://members.evolt.org/jeff/code/preload_n_rollover/

Thanks for the reference.

> > there can't be many people using
> > IE 3 but I'd still prefer a script that didn't
> > produce any error messages at all.
> 
> you think they're not used to seeing those errors by now?

That's no reason for me to ignore some users when I know
there's a solution that fails gracefully for them.

> have you tested whether or not the older, troublesome browsers understand
> the different language values?  my guess is that ie3 will ignore the js1.1
> language specification and try to read the contents anyway.  i was quite
> surprised to see that nn2.02/win didn't do that, but wouldn't be surprised
> if there were some that did (nn3/win, for example, ignores js1.2
> declarations and reads the contents anyway).

Nope, IE3 and NS2.02 ignore the JS1.1 script whilst NN3 runs it (Win).

> > If not, the alternative is to have the first script
> > be JavaScript1.1 and have it set a variable.  The
> > second script (which doesn't need a JS version)
> > then just has to test whether tha variable has been
> > set before the image and function definitions.
> 
> seems like alot of extra work for a browser that you may never have at your
> site.

Well, the setting/testing of a version variable is one of
the suggested compatibility approaches in O'Reilly's book
_JavaScript: A Definitive Guide_ (3rd Ed).

> you're sending extra kb down the pipe for *every* browser so you can
> catch the problem for likely less than 0.1% of your browser users.

I don't know what extra KB you're referring to.  The combined
code of my proposed mouseover scripts for 3 buttons are about
760 bytes.  When I use yours for the same buttons, it's over
a kilobyte (or 750 bytes without the indentation).

Since you've said that it's not illegal to define the same
function twice in consecutive scripts, I won't need to do
explicit JS version testing.  And since this new script
stops IE3 error messages with only an extra 30 bytes (compared
to testing for document.images), I think it's a better
alternative.

I've now tested the script on:
- IE 3.0, 4.0, 5.5 (Win)
- NS 2.02, 3.04, 4.7, 4.72 (Win); 4.77 (Linux); 4.0.5 (Mac)
- Mozilla 0.9+ (Linux)
- Opera 5.11 (Win)

It's in action at http://www.limitless.co.uk/~paola/tmp/thelist/
If anyone finds any JS errors (or display oddities) when using
it on other browsers, please let me know.


Paola





More information about the thelist mailing list