HTML <a> value of an element with href = "javascript :;"
Sometimes I see an HTML <a> element, the href attribute is a URI that only has javascript for the schema, and an empty statement ; for the way.
What is the purpose of this?
This is the same as
href="javascript:void(0);"?Is it compatible with the
hrefattribute?Is it the same as not having an
<a>element at all?
Update
The exact content that I see is <a href="javascript:;" style="cursor: default;"></a> <a href="javascript:;" style="cursor: default;"></a> . So is this just a way to control cursor graphics?
Below you can understand:
<a onclick="foo()">Next Image</a> <a href="#" onclick="foo()">Next Image</a> <a href="javascript:foo()">Next Image</a> <a href="javascript:void(0)" onclick="foo()">Next Image</a> <a href="#" onclick="foo(); return false;">Next Image</a> method 1 usually does not change the mouse cursor to a "manual cursor", so perhaps this is not so desirable in some cases.
method 2 seems to make the page move to a new place, sometimes on IE 6 and IE 7. (at the top of the page?)
method 3 ... should work ... but is this an old school method and should be avoided for modern browsers?
method 4 should work well. void-the-void / author seems to suggest that he sometimes break and never try to use href="javascript:[anything]"
Can method 5 work best? according to the above article, this may be the best way, since it does not use href="javascript:[something]" , and the returned false part will cause href = "#" to not be evaluated, so what's the best way? Thank you so much!