Before the project, use the hyperlink, in IE no problem, but to the IE6, actually found that the click event does not work, #FormatImgID_0 # really incredible, didn't notice before, then the Internet search, the problem on this void (0)! Now the information on the Internet has been sorted out.
HTML code #FormatImgID_1 #<ahref= "javascript:void (0)" onclick= "dosomething ();" >doSomethind</a>
Let's first look at the meaning of Void (0) in javascript:
In JavaScript, Void is an operator that specifies that you want to evaluate an expression but not return a value.
void operator usage format is as follows:
HTML code #FormatImgID_2 #javascript:void (expression) javascript:void expression
Expression is an expression of the JavaScript standard to compute. The parentheses outside the expression are optional, but writing is a good habit. We can use the void operator to specify a hyperlink. The expression is evaluated but does not load any content in the current document. Surface code creates a hyperlink that will not happen when the user clicks on it. When the user clicks on the link, void (0) evaluates to 0, but there is no effect on JavaScript.
HTML code #FormatImgID_3 #<ahref= "javascript:void (0)" > Click here Nothing will happen </a>
That is, you can use void (0) to perform some processing, but not to refresh the page as a whole, but be careful when you need to refresh the page.
HTML code #FormatImgID_4 #<ahref= "Javascript:void (Document.form.submit ())" >
In fact, we can use the above code, this sentence will be a submit operation. What is the case with void (0) More, no refresh, of course, Ajax, look at the AJAX Web page, the general will see a lot of void (0),:D So before using void (0), it's best to think about whether the page needs to be refreshed as a whole.
HTML code #FormatImgID_5 #<scripttype= "Text/javascript" > Function Gourl (x) {window.location.href=x;} </ script><ahref= "javascript:;" onclick= "Javascript:gourl (' http://www.sina.com ');" > Jump 1</a><ahref= "javascript:void (0);" onclick= "Javascript:gourl (' http://www.sina.com ');" > Jump 2</a><ahref= "javascript:void (0);" onclick= "Javascript:gourl (' http://www.sina.com '); return false;" > Jump 3</a><ahref= "#" onclick= "Javascript:gourl (' http://www.sina.com ');" > Jump 4</a><ahref= "###" onclick= "Javascript:gourl (' http://www.sina.com ');" > Jump 5</a>
Test Environment Ie6,ie7,firefox 3.
Jumps 1 and 2 are not valid in the IE6 environment, 3, 4, 5 under the ie6,ie7,firefox3.01 test all can pass,.
Jump 4 and 5 are the most concise.
The key is the href attribute of <a>, the null link with "#", "###".
In order not to return to the top of the page.
"###" is recommended for empty links.