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

Stephen Rider evolt_org at striderweb.com
Thu Mar 3 17:04:17 CST 2005


On Mar 3, 2005, at 4:12 PM, Robert Vreeland wrote:

>> 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.
> Try:
> <a href="javascript: swapImage(); return false;">
> or
> <a href="#" onclick="return swapImage(); ">
> Note, your function will need to return false.

No dice. I'm noticing (quickly) that IE does in fact swap the image,  
but then almost instantly follows the link.

> My guess is your function  throws an error, and then the link gets  
> followed:

Possible, but please note that this works just fine in Firefox, and  
Firefox shows no errors in Javascript console.  (in Safari it swaps and  
resizes the image, but doesn't resize the window...)

Again, here's the test page  (Normally, this is a popup without its own  
URL):
<http://www.realtymort.com/neighborhoods/lincolnpark/fp-530warlington/ 
studio1/popuptest.htm>

Steve



More information about the thelist mailing list