Javascript onclick return false does not work in IE6, IE7 - workaround

Author: Anonym40513
[Report] 11/27/2007 11:49
Instead of:

onclick="yourCodeHere(); return false;"

Use this:

onclick="yourCodeHere(); event.returnValue=false; return false;"

Keywords: internet explorer, ie7, ie6, bug, javascript source code example, javascript

Comments
Author: Anonym73691
[Report] 04/04/2008 16:12
thx guy, it works, you save me :D
Author: Anonym77484
[Report] 04/19/2008 22:22
Yep, it worked here too. Thanks. RTB from Texas.
Author: Anonym78881
[Report] 04/25/2008 20:21
Oh... you are a life saver.
Author: Anonym88693
[Report] 06/29/2008 08:08
Thank you Thank you Thank you!!! from Singapore
Author: Anonym77923
[Report] 08/06/2008 23:02
thank you from Dealermade.com
Author: Anonym83954
[Report] 09/29/2008 15:40
thanks from paris!!!!
Author: Anonym83993
[Report] 09/29/2008 17:35
*Echoes* everyone's praises! Thank you from London!!!!!!
Author: Anonym86993
[Report] 10/15/2008 12:02
You are the best! I spent a hour trying to fixed not working return false javascript for image swapping...
Author: Anonym87005
[Report] 10/15/2008 12:53
Thanks from India you are a real genuis man Hatsoff to you
Author: Anonym119785
[Report] 02/27/2009 09:52
Thanx a Lot......
Author: Anonym122651
[Report] 03/15/2009 03:54
THANKS
Author: Anonym135809
[Report] 05/22/2009 07:33
Thanks! return false; suddenly stopped working in this script I am working on and I have no idea why. This works perfectly.
Author: Anonym150771
[Report] 08/24/2009 11:53
Thanks a lot! For some reason it didnt work this way: onclick="yourCodeHere(); event.returnValue=false; return false;"

So i changed the order and now its working!
onclick="event.returnValue=false; yourCodeHere(); return false;"

Thanks again!
Author: Anonym156841
[Report] 09/30/2009 13:14
Ridiculous assertion. Show us code from a real world situation with this wrong behavior. I can predict it will be a human error and not what you "think" you found out.
Author: Anonym156841
[Report] 09/30/2009 13:15
A page entitle "Javascript onclick return false does not work in IE6,
IE7 - workaround", which is contrary to years of practical experience
and so almost certainly untrue. Lets be very clear about this;
clicking the link in the following simple HMML page does not result in
navigation on IE 6 or 7 (with javascript enabled, of course).

<html>
<head>
<title></title>
</head>
<body>
<a href="http://www.google.com/"; onclick="return false;">
Link to google
</a>
</body>
</html>

Some random assertion to the contrary does not change that, and in
fact seriously being into question the competence of the person making
that assertion.
Author: Anonym158252
[Report] 10/05/2009 03:09
"ridiculous assertion" et al..

There is a bug in IE 6 that is intermittent. The people above are perfectly sane and very frustrated like I am from having to chase down the solution to this problem. It appears on some installations of IE6/7, and in some circumstances only. I have a page where 2 different elements use the same onclick code, one element works as expected and one doesn't. Thanks to the fix above, they both work fine.
Author: Anonym160190
[Report] 10/14/2009 00:16
HI you are great..thanks for solution..keep posted the answers
Author: Anonym164340
[Report] 10/29/2009 09:57
Thanks from Bangalore
Author: Anonym185506
[Report] 01/25/2010 05:29
not only is this a bug in ie7 its in ie8 as well
Author: Anonym188308
[Report] 02/09/2010 13:49
Works great! Thanks a lot from Norway ;-)
Add Entry
 
TOPlist