Entry
If I use the reference such as href = "javascript:myfunc()", animation banners after click stop change of the staff (stop). How it to avoid?
Animated gif not working after mouseover in Netscape.
Dec 21st, 2000 19:42
Juergen Thelen, Yuri Chernyshev,
Yeah, you got trapped by one of the famous NN4 features... :O)
Clicking armed HREFs fires an abort event in NN4 (same effect as if
clicking the Stop button in NN4s menubar). Obviously the people at
Netscape tried to be provident here, assuming that someone clicking
HREFs is going to leave the current document.
Side effects are that any animated GIFs will immediately stop playing
and the hand cursor changes to hourglass cursor as long as staying on
top of this HREF.
As long as loading a new document using a HREF is really intended, this
makes sense by all means, but if the programmer just wants to call a
javascript function instead, this reverts to unwanted behaviour.
Don't worry, such situations were deliberated as well... :O)
So, if you just want to call a javascript function through a HREF, but
nevertheless avoid stopping animated GIFs and appearance of hourglass
cursor, then use something like this:
<a href="javascript:void(0)" onClick="YourJavaScriptCode; return false">
javascript:void(0) is a function that absolutely does nothing, but it
also is a valid HREF attribute that you will need in order to use some
event handlers (like onMouseOut/onMouseOver for example).
Due to its higher priority the onClick handler will be executed before
the action associated with the HREF attribute. Fortunately, since
JavaScript 1.1 (NN3) the onClick Handler has the ability to cancel its
associated click event, so just execute the code/functions you want
inside the onClick handler and then return false to cancel the click
event...
Hope this helps.
Juergen