HTML code
- <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
- JavasAuthorization: void (exprEssion)
- 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
- <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
- <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
- <SCRIPT type = "text/javasOther ">
- 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>
<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 "###".