JS 2 (Application tips of a href)

Source: Internet
Author: User

When I was writing JavaScript yesterday, I suddenly wrote a hyperlink and thought of the following questions. Html code: [html] <a href = "javascript: void (0)" onclick = "" showMesg ('zw1')> view Details </a> <a href = "javacrept: showMesg ('zw1')"> View Details </a> JS Code: [html] <script> function showMesg (obj) {}</script> think of the differences between the two hyperlinks above. Although the final effect is the same, but what is the difference? Search for the materials and summarize them as follows: www.2cto.com can use href and onlick in a hyperlink. Sometimes it must be used at the same time as a tag, sometimes let href work or expire (1) <a href = "#"> </a> after clicking it, the scroll bar will be rolled to the top of the page (2) <a href = "# top"> </a> when the page displays the position of the anchor whose id is top (3) <a href = "#" onclick = "javascript: method "> </a> call a javascript method to roll the scroll bar to the top of the page (4) <a href =" # "onclick =" javascript: method; return false; "> </a> call a javascript method and do not roll the scroll bar to the top of the page (5) <a href =" javascript: void (0) "> </a> no operation is performed after a click (some problems may occur in IE, such as: causes the GIF animation to stop playing) (6) <a href =" javascript: void (0) "onclick =" javascript: method; "> </a> calls a javascript method and does not roll the scroll bar to the top of the page.

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.