IE6 with HREF set to javascript:void (0) page cannot be submitted

Source: Internet
Author: User
Keywords Nbsp; java void (0) submitted
Tags class click code expression function html html code http
<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:

&lt;a class= "bt_3" href= "javascript:void (0)" id= "BtnSubmit1" onclick= "submitpage (); &gt; Submit &lt;/a&gt;

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 &lt;a href= "javascript:void (0)" onclick= "dosomething ();" &gt;doSomethind&lt;/a&gt;


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 &lt;a href= "javascript:void (0)" &gt; Click here Nothing will happen &lt;/a&gt;


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 &lt;a href= "Javascript:void (Document.form.submit ())" &gt;


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 &lt;script&nbsp;type= "Text/javascript" &gt;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; Function&nbsp;gourl (x) {&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; window.location.href=x;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;}&nbsp; &nbsp; &nbsp; &lt;/script&gt;&nbsp; &nbsp; &nbsp;&nbsp; &lt;a&nbsp;href= "javascript:;" &nbsp;onclick= "Javascript:gourl (' http://www.sina.com ');" &gt; Jump 1&lt;/a&gt;&nbsp; &nbsp; &nbsp; &nbsp;&lt;a&nbsp;href= "javascript:void (0);" &nbsp;onclick= "Javascript:gourl (' http://www.sina.com ');" &gt; Jump 2&lt;/a&gt;&nbsp; &nbsp; &nbsp; &nbsp;&lt;a&nbsp;href= "javascript:void (0);" &nbsp;onclick= "Javascript:gourl (' http://www.sina.com ');return&nbsp;false;" &gt; Jump 3&lt;/a&gt;&nbsp; &nbsp; &nbsp;&nbsp; &lt;a&nbsp;href= "# &nbsp;onclick=" Javascript:gourl (' http://www.sina.com '); " &gt; Jump 4&lt;/a&gt;&nbsp; &nbsp; &nbsp;&nbsp; &lt;a&nbsp;href= "###" &nbsp;onclick= javascript:gourl (' http://www.sina.com '); " &gt; Jump 5&lt;/a&gt;&nbsp; &nbsp;

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 "###".

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.