The difference between the href and the onclick of a label

Source: Internet
Author: User

The following sections are turned:

The linked onclick event is executed first, followed by the action under the HREF attribute (page jump, or JavaScript pseudo link), assuming that the link has both href and onclick, and if you want the action under the HREF attribute to not execute, the onclick must get a FAL The return value of SE. No, you can comment out return false in the Gogoogle function, if the page has a scroll bar too long and you want to perform the action through the linked onclick event. Its href attribute should be set to Javascript:void (0) instead of #, which prevents unwanted page jumps, and if a function with a return value is invoked in the linked href attribute, the contents of the current page will be replaced by the return value of the function; Holding down the SHIFT key makes a difference. The problem I encountered today is not accessible to parentnode in the form of href in IE6.0. Try not to use JavaScript: protocol as the HREF attribute of a, which will not only cause unnecessary trigger window.onbeforeunload events, in IE will make GIF animated pictures stop playing

Here are some of your own encounters:

If you do not set the href property below IE6, you will not respond to hover. Double-clicking will select the label's parent container instead of the one-a label (this problem exists under IE). <a href= "JAVASCIRPT:FN (This)" > <a onclick= "fn (this)" > Suppose we have a FN method that needs to be taken to this element, the first method to pass in the This is a null value.

Therefore, the comparison recommendation is <a href= "javascript:void (0)" onclick= "FN (this)" >

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.