1 linked onclick
events are executed first, followed by href
actions under attributes (page jumps, or JavaScript pseudo-links);
2 assume that the link exists in the same time href
onclick
, if you want href
the action under the property is not executed, onclick
you must get a false
return value;
3 If the page has scroll bars too long and you want to perform the action through the linked onclick
events. Its properties should be href
set to javascript:void(0);
, not to be #
, this prevents unnecessary page jumps;
4 if href
a function with a return value is called in the linked property, the contents of the current page will be replaced by the return value of the function;
5 There is a difference when you hold down the SHIFT key.
6 in IE6.0 in the form of href access to parentnode.
7 Try not to use JavaScript: protocol as the HREF attribute of a, which will not only lead to unnecessary triggering of window.onbeforeunload events, in IE will make GIF animated pictures stop playing.
In JavaScript, Void is an operator that specifies that an expression is evaluated but does not return a value.
The void operator uses the following format: 1. Javascript:void (expression) 2. Javascript:void expression
Expression is a standard of Javascript to evaluate. Parentheses on the outside of the expression are optional, but writing is a good habit. (Implementation version Navigator 3.0)
You use the void operator to specify a hyperlink. The expression is evaluated but does not load anything at the current document.
The following code creates a hyperlink, and nothing happens when the user clicks it. void (0) evaluates to 0 when the user links, but does not have any effect on Javascript.
<a href= "javascript:void (0)" > single here Nothing will happen </A>
The following code creates a hyperlink that submits a form when the user clicks it.
<a href= "Javascript:void (Document.form.submit ())" >
Submit form here </A>
The following code executes the SUBGO () function,
<a href= "javascript:void (0)" onclick= "Subgo ()" > Point me </a>
Here, javascript:void (0), does not have a substantial effect, it is just a dead link, the function that executes is subgo ().
<a href= "#" onclick= "Subgo ()" > Point me </a> with <a href= "javascript:void (0)" onclick= "Subgo ()" > Point me </a> Difference.
In fact #包含了一个位置信息默认的锚是 #top is the upper end of the page, and javascript:void (0) simply represents a dead link with no information. So it's best to use void when calling scripts (0)
href generally refers to a URL address, you can also call JavaScript, such as href= "javascript:xxx ();", recommended in the documentation: <a href= "javascript:void (0)" onclick= "xxx ();" >xx</a> But this approach sometimes creates strange problems in complex environments, try not to use JavaScript: protocol as the HREF attribute of a, This will not only lead to unnecessary triggering of window.onbeforeunload events, in IE will make GIF animated pictures stop playing.
The onclick event of the link is executed first, followed by the action under the HREF attribute (page jump, or JavaScript pseudo-link), and if you do not want the action under the HREF attribute to be executed, the onclick needs to return false, which is generally written onclick= "xxx (); return false; ".
Original address: http://www.cnblogs.com/happykakeru/archive/2011/10/24/2222702.html
<a> the href and onclick properties of the tag "go"