By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,742 Members | 2,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,742 IT Pros & Developers. It's quick & easy.

href and onclick property of anchor tag.

dmjpro
100+
P: 2,476
Today i encountered a problem with anchor tag in IE 6.
Basically it is told that ... we should write ..

Expand|Select|Wrap|Line Numbers
  1. <a herf="javascript:void(0);" onclick="function_call(..);return false;">Display Name</a>
Why it is suggested? If inside that function call if i try to change the href value that window then it does not work if i don't have return false statement after function call. If i have that then it works. But if i have return false inside the function then it also does not work. Why does it happen ?
Sep 24 '08 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
Expand|Select|Wrap|Line Numbers
  1. onclick="function() {return false;}" --> onclick="false"
  2. onclick="return function() {return false}" --> onclick="return false"
  3. // compare to
  4. onclick="function() {...}; return false;" --> onclick="{some action}; return false;"
these are two different statements

I think it has something to do with the fact that both the event and the hypertext reference fire on click.
Sep 24 '08 #2

dmjpro
100+
P: 2,476
Expand|Select|Wrap|Line Numbers
  1. onclick="function() {return false;}" --> onclick="false"
  2. onclick="return function() {return false}" --> onclick="return false"
  3. // compare to
  4. onclick="function() {...}; return false;" --> onclick="{some action}; return false;"
these are two different statements

I think it has something to do with the fact that both the event and the hypertext reference fire on click.
Oh Shit!
Sorry i could have explained myself ...shame on me ... :(
Anyway thanks ....
Sep 24 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.