Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use location.hash

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to use location.hash for you. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The hash attribute is a readable and writable string that is the anchor part of the URL (starting with the # sign). As far as I can remember, this is the first time that a mainstream website has used "#" on a large scale in a key URL that directly interacts with users. This shows that the role of the pound sign (Hash) is being rerecognized. According to the article of HttpWatch, this paper collates all the important knowledge points related to the pound sign.

Location.hash browser support

InternetExplorerFirefoxOperaGoogleChromeSafari

All major browsers support the hash property

Returns the main part of a URL. Suppose the current URL is # PART2:

[xss_clean] (location.hash)

The output result of the above example:

# part2

Location object reference manual Location object

A significant change is that URL has added "#!" Symbols. For example, the URL of the user's home page before the revision is

Location.hash detailed explanation

I. the meaning of

# represents a location on a web page. The character to the right of it is the identifier of that location. such as,

It represents the print location of the web page index.html. After the browser reads the URL, it automatically scrolls the print position to the visual area.

There are two ways to specify an identifier for a page location. One is to use anchor points, for example, and the other is to use the id attribute, such as.

2. The HTTP request does not include #

# is used to guide browser actions and is completely useless on the server side. Therefore, # is not included in the HTTP request.

For example, visit the following URL

The actual request from the browser is as follows:

GET/index.htmlHTTP/1.1

Host:www.example.com

As you can see, there is no "# print" part of the request only for index.html.

This is the end of the article on "how to use location.hash". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report