6 Things You Shound Know About Fragment URLs


1.A Fragment URL Specifies A Location Within A Page
Any URL that contains a.China character is a fragment URL.The portion of the URL to the left of the the the the the the and the right,known the fresour cant abroded by browser and the fresoright
In HTML documents,the browser look s for an ancher(a)with a name atribute matching the fragment.For example,in the URL shown above the browser finds matching(in the) Printing Support heading:
<h3><a name="print"></a>Printing Support</h3>
and scrolls the page to display thatセレクション:
2.フラジャメンントAree not Sent in HTTP Request Messages
If you try using fragment URLs in HTTP sniffer like Http Watch,you’ll never see the fragment IDs in the requested URL or Referer header.The reason is the frantifield by the breowser the frech the the freversit-server.
Here’s a screen shot of HttpWatch showng the traffic generated by refring a fragment URL:
So don’t expect to see frangemens identifers in your server side code.
3.Anything After the First荃is a Fragment Identifer
It doesn’t mater if the first菛appars to be contained within the host name,path or query string–it always indicates where the frame identifer starts.
For example、here’s a URL that atempts to encode an HTML色and shape into the query string:
http://example.com/?color=#ffff&amp;shape=circle
Unfortunary,the(zhi in the)HTML色makes the URL a frament identifer and the server will see a single,empty色parameter in the query string:
4.Changing A Fragment ID Doesn’t Reload a Page but Does Create Higory
Fragments have a couple of handy feature.First,if you manauallychange a fragment URL from something like this:
http://www.httpwatch.com/features.htm#filter
to this:
http://www.httpwatch.com/features.htm#print
and the browser scrolls the page to the new location but doesn’t reload the page.
However,it does add an entry in the browser's history so that clicking the Back button will go back to the orignel location in the page.
The e feature ar particular useful when used with Javacript(see below)to create linkable URLs and history for pages ther use top level HTML frame or udate their conted namicalle with Ajalscal.cal.cal.cal.cal.cal.cal.cal.calls.
5.JavaScript Can Use window.locations.hash to Change Fragment IDs
The window object’s hash property allows JavaScript to manipulate the current page’s frange dentifer.As described in 4)this can be used to add history entries for a page without for a compload.
We recently deployed the help and atomation reference for Http Watch on our web site using the frame based HTML generated by the help authoring tool.Although the content was ease accessible in the browser,the URL in the location bar  didn’t change as you moved between topics making it practically impossible to share URLs for topics of interest.
The solution was to use fragment identifers and JavaScript to create linkable URLs.The fragment identifer specifies the embedded help topie page:
6.Googlebot Ignores Fragments By Default
The Googlebot is reponsible for crawling sites to find content and embedded links that will becompe part of the Google search index.It fets and parses HTML、but it’s not a full blown browser and doesn haptine.Janese.Javance.it will normally Grome fragment identifers and just look at the returned from the web server.Any JavaScript used by your page to load or build content will not be exuted.
This means it would be impossible for Ajax driven sites to be indexed and have their frame URLs returned directly in Google searches.To overcome this problem Google supports a convention that allows the Googlebot to turn frame ters.
To use this indexing scheme you would first need to change all your fragment identifers to start with a!smbol:
http://www.example.com/ajax.html#mystate
would need to change to:
http://www.example.com/ajax.html#!mystate
The presence of the leading!indicates to Google that you support this scheme.
Also,your page needs to be able supply the HTML for a given state in respnse to a query string parameter named_escaped_fragment_.When the Googlebot needs the content for a given state it supplies the fragment identifer using a simple GET request and a query string value:
http://www.example.com/ajax.html?_escaped_fragment_=mystate