| re: Javascript toggles div visibility, img elements dissappear
dwilson wrote:[color=blue]
> I am having a strange Javascript issue. I have a div that
> I show and hide by clicking on an image link, and all
> images within the div do not show up in IE. FireFox does
> not give me this problem. Also, under[/color]
<snip>
So, in IE only, the user clicking on something causes the browser to
stop working in the way it previously had. Those are the symptoms of the
use of a javascript pseudo-protocol HREF.
[color=blue]
> <a href="javascript:splodeDiv('folder Group1',
> 'expandRetract1');"> ...[/color]
<snip>
And there it is. IE treats the activation of a javascript
pseudo-protocol HREF as navigation, and when used the browser goes into
a 'waiting state' pending the arrival of a replacement for the content.
In this state many previously available browser facilities are
withdrawn, including GIF animation and image swapping.
The normal strategy for dealing with this issue is to never use a
javascript pseudo-protocol HREF that will not result in the replacement
of the contents of the current page (so never to execute a function for
its side effect).
Usually the same effect as a javascript pseudo-protocol HREF can be
achieved (without the detrimental consequences in IE) with a suitably
default action cancelling intrinsic event handler. An onclick handlers
are the usual replacement. So, something like:-
<a href="someURL"
onclick="splodeDiv('folder Group1','expandRetract1');return false;"[color=blue]
> ... </a>[/color]
Where - someURL - is the url of a resource that should never be visited
while javascript is available/enabled because the click event is
cancelled by its handler returning false, and so may act as an
alternative to the scripted action, or apologise to the user for the
needless creation of a javascript dependent web site.
Richard. |