Javascript: void (0);, herf = "#" and click event invalidation in IE6

Source: Internet
Author: User

In some webpages, the <a href = "#"> "#" in herf is changed to javascript: void (0), because # contains a location information, the default anchor is # top, that is, the top of the web page. javascript: void (0) only indicates a dead link.
This is why sometimes a long page browsing link is clearly # But the page jumps to the top, while javascript: void (0) is not.

Ajax technology is generally used in this form, and our project only adds a click event to process some verification logic and then jumps... The problem arises. in IE6, the click event fails...

The following explanation is found on the Internet:

Here href = "javascript:; or Javascript: void (0 or null);" itself means to execute an empty event. The response sequence starts from onclick and then enters href. The problem here is that the empty response of href is executed after the onclick link event is executed. So it becomes invalid.
The solution is to add return false to onclick (that is, do not execute the event in href ). As to why other browsers do not support this problem, it can be explained that "the default value behind other browsers is to keep up with return false; while IE6 is to return true; "Note that this conclusion remains to be verified.

Return false. This is not acceptable...

Another solution is to use ###...

Okay, the problem is solved ..

But is that complicated. Why should I use the <A> label and a <span> problem...

Sometimes, you have to think about problems from multiple perspectives .. Occasionally jump out and look at the problem. There are often new ideas ......

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.