A href= "javascript:" with a href= "#"

Source: Internet
Author: User

<href= "javascript:;" ></ a >    <  href= "#"></a>

These two kinds of wording. What is the difference between these two types of writing? What kind of writing is more standard?

href= "#" refers to the connection to the current page, in fact, is meaningless, the page will not be refreshed. This is a chain connection.

In the HTML language when making the page parameters, used to specify the URL of the link # # # #就是本页链接, href= "address" is linked to the address link to the default page, not pop-up window, empty connection, if you remove #, the mouse hand cursor is not displayed. The popular point is a false link to this page can also be followed by the # anchor ID This is actually another use of a bookmark.

Syntax: <a href= "#书签的名称" > linked text </a>

Bookmarks linked to different pages

Syntax: <a href= "link file address # bookmark name" > linked text </a> (note quotes and # numbers)

Under normal circumstances click: <a href= "#书签名称" > linked text </a> this link, the cursor will automatically jump to this page: <a name= "bookmark name" > Text </a> location.

If we just want to write a tag that doesn't have any event jumps happening. I personally do not recommend using <a href= "#" > This notation.

But the href attribute can also identify JavaScript snippets.

Where javascript: is a pseudo-protocol. It allows us to invoke JavaScript functions through a link. But because this function is empty, we call an empty function, and there is no real change. You can also implement a-tag click-to-run. If there is a lot of content inside the page, there is a scroll bar, using href= "#" will jump to the top of the page problem. Instead of using href= "javascript:;" You can avoid page jumps!

So, if we want to write a dead a tag, use

<href= "javascript:;" ></ a >

will be more conducive to increasing the user-friendliness of our pages!

Transferred from: http://blog.csdn.net/u011277123/article/details/53389898

A href= "javascript:" with a href= "#"

Related Article

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.