A label is mainly used to achieve page jump, can be achieved through the HREF attribute, can also be implemented in the OnClick event.
The code is as follows:
<a onclick= "window.location.href= ' www.jb51.net '" href= "javascript:void (0);" > Triple </a>
This code in the mainstream browser is no problem, but under the IE6 will be unable to jump the problem. What is the reason for this?
The code is as follows:
Javascript:void (0);
void (ARG), which can be interpreted as a function that returns null forever, but whose arguments cannot be null. Its arguments can be any expression or even a function.
The code is as follows:
<a href= "Javascript:void" (name = ' Triple '); alert (name); " > Testing </a>
Test
IE6 first runs the events that the DOM itself binds, such as onclick; if bubbling is not blocked, the href attribute is executed sequentially. and void (0); It is not necessary to perform any event, then IE6 tells the browser not to perform any event (overwriting the previous action), and terminating bubbling is equivalent to return false, so the browser does not perform any action. So just block the bubbling event within the onclick event.
The code is as follows:
<a onclick= "window.location.href= ' http://www.jb51.net '; return false;" href= "javascript:void (0);" > Triple </a>
This will work properly under the IE6.
Another method is to not use Javascript:void (0), and to use # can also be avoided, the href attribute of the # inherently means the anchor point #name so that when no anchor point is assigned to the top of the page. #是有特定意义的, the default is #top, if the # after the content will be considered a label and from the page to find the corresponding label jump to the place, can not find to jump to the top of the page, if you do not want to jump, you may use the ###,## #就是一个无意义的标签指定.