Javascript onclick return false does not work in IE6, IE7 - workaround
Instead of:
onclick="yourCodeHere(); return false;"
Use this:
onclick="yourCodeHere(); event.returnValue=false; return false;"
onclick="yourCodeHere(); return false;"
Use this:
onclick="yourCodeHere(); event.returnValue=false; return false;"
Answers
Discussion
So i changed the order and now its working!
onclick="event.returnValue=false; yourCodeHere(); return false;"
Thanks again!
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.
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.
for me this code is not working.. any other solution so that onclick works in IE6
Thanks from Romania!!!
sanjuro, http://www.1up-games.com
I fixed it by preceeding it with an IE check:
if ( $.browser.msie ) { event.returnValue=false; }
Thanks it works fine.. how about other browsers??
Let me see!!!!!!
YOU ARE REALLY GREAT
A REAL SUPER CODER
return false is equal to event.returnValue
but sometimes not work becoz of dom portability
for ex:-
OnClientClick="return confirm('Are you sure want to Delete this file?');" (Not working)
OnClientClick="event.returnValue=confirm('Are you sure want to Delete this file?');" (Working fine)
mail me subratnayak09@gmail.com