[thelist] javascript ignores "return false" in IE ?

Christian Heilmann lists at onlinetools.org
Thu Mar 3 16:27:12 CST 2005


Stephen Rider wrote:

> I'm completely confused.  I have the following link that runs a 
> javascript:
>
> <a href="index.htm" onclick="swapImage(); return false;">
>
> (i've also tried it as:  a href="" )
>
> The "return false" should prevent loading index.htm when a user clicks 
> the link, but in IE (and it seems only in IE) it doesn't.  The script 
> runs and then the browser goes to index.htm.
>
> Does anyone know how to fix this?  I don't want the browser to go to a 
> different page!


My guess is your function  throws an error, and then the link gets followed:
http://www.onlinetools.org/tests/returnfalse.html

The  first bla works, the second one fires off a buggy function and will 
load google.

Why you want to  neuter a link for an image change is another question, 
but I  think you have your reasons...




More information about the thelist mailing list