Differences between different browsers

Source: Internet
Author: User

HTML code

  1. <A href = "javasAuthorization: void (0) "onClick = "dosomething ();"> dosomethind </a>

<A href = "javasAuthorization: void (0) "onClick = "dosomething ();"> dosomethind </a>

Let's take a look at javas.Meaning of void (0) in dimensions:

JavasVoid is an operator in vertex. It specifies that an expression is to be calculated but no return value is returned.

The format of the void operator is as follows:

HTML code

  1. JavasAuthorization: void (exprEssion)
  2. JavasAuthorization: void exprEssion

JavasAuthorization: void (exprEssion) javasAuthorization: void exprEssion

ExprEssion is a javas to be calculated.The limit standard expression. Parentheses outside the expression are optional, but it is a good habit to write. You can use the void operator to specify a hyperlink. The expression is calculated, but no content is loaded in the current document. The code above creates a hyperlink, and nothing will happen after the user clicks. When a user clicks a link, void (0) is calculated as 0, but in javasThere is no effect on the slave.

HTML code

  1. <A href = "javasWarning: void (0) "> click here nothing will happen </a>

<A href = "javasWarning: void (0) "> click here nothing will happen </a>

That is to say, if you want to perform some processing, but do not refresh the page as a whole, you can use void (0). However, when you need to refresh the page, you have to be careful.

HTML code

  1. <A href = "javasAuthorization: void (document. Form. Submit () ">

<A href = "javasAuthorization: void (document. Form. Submit () ">

In fact, we can use the above Code to perform a submit operation. Under what circumstances will void (0) be used more often, without refreshing the new version? Of course it is Ajax. If you look at Ajax web pages, you will usually see a lot of void (0 ),: D. Before using void (0), you 'd better think about whether the page needs to be refreshed as a whole.

HTML code

  1. <SCRIPT type = "text/javasOther ">
  2. Function gourl (x ){
  3. Window. Location. href = X;
  4. }
  5. </SCRIPT>
  6. <A href = "javasUsage:; "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> redirect 1 </a>
  7. <A href = "javasAuthorization: void (0); "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> redirect 2 </a>
  8. <A href = "javasAuthorization: void (0); "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); Return false; "> jump 3 </a>
  9. <A href = "#" onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> jump to 4 </a>
  10. <A href = "###" onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> jump to 5 </a>

<SCRIPT type = "text/javasHandler "> function gourl (x) {window. Location. href = x ;}</SCRIPT> <a href =" javasUsage:; "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> redirect 1 </a> <a href =" javasAuthorization: void (0); "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> redirect 2 </a>
<A href = "javasAuthorization: void (0); "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); Return false; "> jump 3 </a> <a href =" # "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> jump to 4 </a> <a href =" ### "onClick = "javasRedirect: gourl ('HTTP: // www.sina.com '); "> jump to 5 </a>

Test Environment IE6, IE7, and Firefox 3.

The redirection 1 and 2 are invalid in IE6, and both 3, 4, and 5 pass the tests in IE6, IE7, and firefox3.01 ,.

Jump to 4 and 5 is the most concise.

The key lies in the href attribute of <A>. For empty links, use "#","###".

In order not to return to the top of the page.

"####" Is recommended for empty links "###".

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.