href and onclick property of anchor tag.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    href and onclick property of anchor tag.

    Today i encountered a problem with anchor tag in IE 6.
    Basically it is told that ... we should write ..

    [code=javascript]<a herf="javascrip t:void(0);" onclick="functi on_call(..);ret urn false;">Display Name</a>[/code]

    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 ?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Code:
    onclick="function() {return false;}" --> onclick="false"
    onclick="return function() {return false}" --> onclick="return false"
    // compare to
    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.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by Dormilich
      Code:
      onclick="function() {return false;}" --> onclick="false"
      onclick="return function() {return false}" --> onclick="return false"
      // compare to
      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 ....

      Comment

      Working...