"#" in the URL? function of the "&" "No.

Source: Internet
Author: User

Read Catalogue

    • 1. #
    • 2.?
    • 3. &
Back to top of 1. #

September 10, Twitter revamped. A significant change is that URLs are added to the "#!" Symbol. For example, before the revision of the user's homepage URL for http://twitter.com/username revision, it became http://twitter.com/#!/username
This is the first time that a major web site uses "#" for a large number of important URLs. This indicates that the function of the pound sign (Hash) is being re-recognized. This article, according to HttpWatch's article, organizes all important knowledge points related to the well number.
First, #的涵义
#代表网页中的一个位置. The character to the right is the identifier for that position. For example, Http://www.example.com/index.html#print represents the print position of the page index.html. When the browser reads the URL, it automatically scrolls the print position to the viewable area.
There are two methods for specifying an identifier for the page location. One is the use of anchor points, such as <a name= "print" ></a>, and the second is the use of ID attributes, such as <div id= "print" >.

Second, the HTTP request does not include #
#是用来指导浏览器动作的, completely useless on the server side. Therefore, # is not included in the HTTP request.
For example, to visit the following URL, Http://www.example.com/index.html#print, the browser actually makes a request like this:

Get/index.html http/1.1host:www.example.com

Third, #后的字符
Any character that appears after the first # is interpreted by the browser as a positional identifier. This means that none of these characters will be sent to the server side.
For example, the intent of the following URL is to specify a color value: http://www.example.com/?color= #fff, but the actual request the browser makes is:

GET/?color= http/1.1host:www.example.com

Iv. Change # does not trigger page reload
Simply change the part of the #, the browser will only scroll to the appropriate location and will not reload the page.
For example, change from Http://www.example.com/index.html#location1 to Http://www.example.com/index.html#location2, The browser does not re-request index.html to the server.

V. Change # will change the browser's access history
Each time you change the # section, you add a record to your browser's access history and use the back button to go back to the previous location. This is especially useful for Ajax applications, where you can use different # values to represent different access states, and then give the user a link to access a state. It is important to note that the above rules do not hold for IE 6 and IE 7, they will not increase the historical record because of the change of #.

Six, Window.location.hash read # value
Window.location.hash This property can be read and writable. When read, it can be used to determine if the state of the Web page changes, and when it is written, it creates an access history without reloading the page.

Vii. Events of Onhashchange
This is a new HTML 5 event that will be triggered when the # value changes. ie8+, Firefox 3.6+, Chrome 5+, Safari 4.0+ support this event.
There are three ways to use it:

    • Window.onhashchange = func;
    • <body onhashchange= "func ();" >
    • Window.addeventlistener ("Hashchange", Func, false);

For browsers that do not support onhashchange, you can use SetInterval to monitor location.hash changes.

Eight, Google crawl # mechanism
By default, Google's web spiders ignore the # portion of the URL.
However, Google also stipulates that if you want AJAX-generated content to be read by the browsing engine, the URL can use "#!", and Google will automatically convert the content behind it into the value of the query string _escaped_fragment_.
For example, Google found that the new version of Twitter's url:http://twitter.com/#!/username
It will automatically fetch another url:http://twitter.com/?_escaped_fragment_=/username
With this mechanism, Google can index dynamic AJAX content.


AJAX = Asynchronous JavaScript and XML (a subset of standard generic markup languages). AJAX is a technique for creating fast, Dynamic Web pages.

Back to top of 2. ?

1) connection function: for example


2) Clear the cache: for example,

Http://www.xxxxx.com/index.html http://www.xxxxx.com/index.html?test123123

Two URLs open the same page, but this one has a question mark, indicating that the cached content is not called, but is considered a new address, re-read.

Back to top of 3. &

Spacers for different parameters




"#" in the URL? function of the "&" "No.

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.