Href = "#" And href = "javascript: void (0 )"

Source: Internet
Author: User

Common <SPAN class = 'wp _ keywordlink '> Code </span>: <br/> <a href = "javascript: dotest2 (); void (0); "mce_href =" javascript: dotest2 (); void (0); "> here </a> <br/> but here void (0) what exactly does it mean? <Br/> in Javascript, void is an operator that specifies to calculate an expression but does not return a value. <Br/> the format of the void operator is as follows: <br/> 1. javascript: void (expression) <br/> 2. javascript: void expression <br/> expression is a standard JavaScript expression to be calculated. Parentheses outside the expression are optional, but it is a good habit to write them. (Implementation version: navigator 3.0) <br/> you use the void operator to specify the hyperlink. The expression is calculated, but no content is loaded in the current document. <Br/> the following code creates a hyperlink. Nothing will happen to the user in the future. When a user links, void (0) is calculated as 0, but JavaScript has no effect. <Br/> <a href = "javascript: void (0)" mce_href = "javascript: void (0) "> nothing happens here. </a> <br/> the code below creates a hyperlink. A form is submitted when a user makes a ticket. <Br/> <a href = "javascript: void (document. form. submit () "mce_href =" javascript: void (document. form. submit () "> <br/> submit a form here </a> <br/> a href = # With a href = javascript: void (0) <br/> # contains a location information <br/> the default anchor is # top, that is, the top of the web page <br/> and javascript: void (0) indicates only one dead link. <br/> This is why a long page browsing link is clearly # Yes <br/> hitting the top. <br/> javascript: void (0) is not the case. <br/> therefore, it is best to use void (0) when calling the script) <br/> or <input onclick> <br/> <Div onclick> and other <br/> links Several methods <br/> 1. window. open (''url') <br/> 2. use a custom function <br/> <MCE: Script Type = "text/JavaScript"> <! -- </P>

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.