当前位置:网站首页>""? "& in URL Role of "" sign

""? "& in URL Role of "" sign

2022-06-13 09:00:00 xiongpursuit88

Read the directory

  1. &
    Back to the top
  2. 10 year 9 month ,twitter Revision . A significant change , Namely URL Joined the "#!“ Symbol . such as , The website of the user's home page before the revision is http://twitter.com/username The revised , It becomes http://twitter.com/#!/username
       This is the first time a mainstream website will ”#" Large scale for important URL in . This shows that the well number (Hash) The role of is being re recognized . This article is based on HttpWatch The article , Sort out all important knowledge points related to well number .
    One 、# Meaning of
      # Represents a location in a web page . The character on the right side of it , Is the identifier of the location . such as ,http://www.example.com/index.html#print On behalf of the web page index.html Of print Location . The browser reads this URL after , Will automatically print Position scroll to viewable area .
       Specify the identifier for the web location , There are two ways . One is the use of anchors , such as , The two is the use of id attribute , such as
    .

Two 、HTTP The request does not include #
  # It's used to guide browser actions , Nothing to do with the server side . therefore ,HTTP The request does not include #.
such as , Visit the website below ,http://www.example.com/index.html#print, The actual request from the browser is like this :

GET /index.html HTTP/1.1
Host: www.example.com

3、 ... and 、# After the character
   At the first # Any character that appears after , Will be interpreted by browsers as location identifiers . It means , None of these characters will be sent to the server .
such as , below URL The original meaning is to specify a color value :http://www.example.com/?color=#fff, however , The actual request from the browser is :

GET /?color= HTTP/1.1
Host: www.example.com

Four 、 change # Do not trigger page overloading
   Just change # The latter part , The browser will only scroll to the appropriate location , The web page will not be reloaded .
such as , from http://www.example.com/index.html#location1 Change to http://www.example.com/index.html#location2, The browser will not re request from the server index.html.

5、 ... and 、 change # Will change the browser's access history
   Every change # The latter part , Will add a record to the browser's access history , Use " back off " Button , You can go back to the previous position . This is for ajax Applications are particularly useful , You can use different # value , Indicates different access states , Then give the user a link to access a certain state . It is worth noting that , The above rules are applicable to IE 6 and IE 7 Don't set up , They don't because # Change to add history .

6、 ... and 、window.location.hash Read # value
  window.location.hash This property is readable and writable . When reading , It can be used to determine whether the state of a web page has changed ; When writing , Without overloading the web page , Create a history of visits .

7、 ... and 、onhashchange event
   This is a HTML 5 New events , When # When values change , Will trigger this event .IE8+、Firefox 3.6+、Chrome 5+、Safari 4.0+ Support the event .
   It can be used in three ways :

window.onhashchange = func;

window.addEventListener("hashchange", func, false);    For not supporting onhashchange Browser , It can be used setInterval monitor location.hash The change of .

8、 ... and 、Google Grab # The mechanism of
   By default ,Google Web spiders ignore URL Of # part .
   however ,Google It also stipulates that , If you wish Ajax The generated content is read by the browser engine , that URL Can be used in "#!",Google It will automatically convert the content after it into a query string _escaped_fragment_ Value .
   such as ,Google Find a new version twitter Of URL:http://twitter.com/#!/username
   It will automatically grab another URL:http://twitter.com/?escaped_fragment=/username
   Through this mechanism ,Google You can index dynamic Ajax Content .

notes

AJAX = asynchronous JavaScript and XML( A subset of Standard General Markup Languages ).AJAX Is a technology for creating fast dynamic web pages .

Back to the top
2. ?
1) Connectedness : such as

http://www.xxx.com/Show.asp?id=77&nameid=2905210001&page=1
2) Clear cache : such as

http://www.xxxxx.com/index.html
http://www.xxxxx.com/index.html?test123123
Two url Open the same page , But there's a question mark on the back , Description does not call the contents of the cache , And think it's a new address , Reread .

Back to the top
3. &
Separators for different parameters

原网站

版权声明
本文为[xiongpursuit88]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270535254891.html