<a class= "Bt_3" href= "javascript:void (0)" id= "BtnSubmit1" onclick= "Submitpage ()" > Submit </a>
Submitpage () is a function of my definition, which is intended to submit a form when clicking this <a>. FT, IE6 incredibly can't, how also can not submit.
It seems that because IE6 performs the default action, there are two solutions:
The first method:
<a class= "Bt_3" style= "Cursor:pointer" id= "btnSubmit1" onclick= "Submitpage" () > Submit </a>
This method does not have the href attribute at all, and uses style= "Cursor:pointer" to produce the hand-shaped icon to simulate.
Another method:
<a class= "bt_3" href= "javascript:void (0)" id= "BtnSubmit1" onclick= "submitpage (); > Submit </a>
OnClick returns false, blocking the browser's default behavior. can also achieve the same purpose.
-------------------------------------------------------------------------------------------
Before in the project, use the hyperlink, in IE no problem, but to the IE6, unexpectedly found that the Click event does not work, really incredible, did not notice before, then the Internet search, the problem on this void (0)! Now the information on the Internet has been sorted out.
HTML code <a href= "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 javascript:void (expression_r) javascript:void Expression_r
Expression_r 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 <a href= "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 <a href= "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 <script type= "Text/javascript" > Function gourl (x) { window.location.href=x; } </script> <a href= "javascript:;" onclick= "Javascript:gourl (' http://www.sina.com ');" > Jump 1</a> <a href= "javascript:void (0);" onclick= "Javascript:gourl (' http://www.sina.com ');" > Jump 2</a> <a href= "javascript:void (0);" onclick= "Javascript:gourl (' http://www.sina.com ');return false;" > Jump 3</a> <a href= "# onclick=" Javascript:gourl (' http://www.sina.com '); " > Jump 4</a> <a href= "###" onclick= javascript:gourl (' http://www.sina.com '); " > Jump 5</a>
The
test Environment Ie6,ie7,firefox 3.
Jumps 1 and 2 are not valid in the IE6 environment, and 3, 4, 5 are tested under ie6,ie7,firefox3.01. The
Jumps 4 and 5 is the most concise. The key to
is the href attribute of <a>, the null link with "#", "###".
to not return to the top of the page.
Null links are recommended with "###".