Questions tagged [fragment-identifier]

The fragment-identifier is the part of the URI/URL following the hash symbol. In the case of `http://mysite.com/page/#/one` then `/one` would be the fragment-identifier.

The fragment-identifier is the part of the URI/URL following the hash symbol. In the case of http://mysite.com/page/#/one then /one would be the fragment-identifier.

In URIs a hashmark # introduces the optional fragment near the end of the URL. The generic RFC 3986 syntax for URIs also allows an optional query part introduced by a question mark ?. In URIs with a query and a fragment, the fragment follows the query. Query parts depend on the URI scheme and are evaluated by the server — e.g., http: supports queries unlike ftp:. Fragments depend on the document MIME type and are evaluated by the client (Web browser). Clients are not supposed to send URI-fragments to servers when they retrieve a document, and without help from a local application (see below) fragments do not participate in HTTP redirections.

A URI ending with # is permitted by the generic syntax and could be considered as a kind of empty fragment. In MIME document types such as text/html or any XML type, empty identifiers to match this syntactically legal construct are not permitted. Web browsers typically display the top of the document for an empty fragment.

The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the web server — of course the server typically helps to determine the MIME type, and the MIME type determines the processing of fragments. When an agent (such as a Web browser) requests a web resource from a Web server, the agent sends the URI to the server, but does not send the fragment. Instead, the agent waits for the server to send the resource, and then the agent processes the resource according to the document type and fragment value.

For more info see wiki.

243 questions
81
votes
8 answers

How can I remove the location hash without causing the page to scroll?

Is it possible to remove the hash from window.location without causing the page to jump-scroll to the top? I need to be able to modify the hash without causing any jumps. I have this: $('').text('link').click(function(e) { …
David Hellsing
  • 106,495
  • 44
  • 176
  • 212
63
votes
5 answers

Remove hash from url

I am ajax-ifying the pagination in one of me projects and since I want the users to be able to bookmarks the current page, I am appending the page number via hash, say: onclick="callPage(2); window.location.hash='p=2'; return false;" and thats on…
iamserious
  • 5,385
  • 12
  • 41
  • 60
63
votes
7 answers

Detecting Back Button/Hash Change in URL

I just set up my new homepage at http://ritter.vg. I'm using jQuery, but very minimally. It loads all the pages using AJAX - I have it set up to allow bookmarking by detecting the hash in the URL. //general functions function getUrl(u) { …
Tom Ritter
  • 99,986
  • 30
  • 138
  • 174
60
votes
4 answers

How does facebook rewrite the source URL of a page in the browser address bar?

Go to http://www.facebook.com/facebook?v=wall, then click on the info tab. The content will be loaded, and the address bar now becomes http://www.facebook.com/facebook?v=info but the webpage didn't reload. At first I think it is Ajax, but my…
cdxf
  • 5,501
  • 11
  • 50
  • 65
56
votes
10 answers

Parsing URL hash/fragment identifier with JavaScript

Looking for a way to parse key pairs out of the hash/fragment of a URL into an object/associative array with JavaScript/JQuery
Yarin
  • 173,523
  • 149
  • 402
  • 512
56
votes
5 answers

Change hash without reload in jQuery

I have the following code: $('ul.questions li a').click(function(event) { $('.tab').hide(); $($(this).attr('href')).fadeIn('slow'); event.preventDefault(); window.location.hash = $(this).attr('href'); }); This simply fades a div in…
daveredfern
  • 1,235
  • 4
  • 14
  • 15
47
votes
18 answers

changing location.hash with jquery ui tabs

I've been trying to find a way to change the window.location.hash to the currently selected tab in Jquery UI Tabs. I've tried: $("#tabs > ul").tabs(); $("#tabs > ul").bind("tabsshow", function(event, ui) { window.location.hash = ui.tab; }) This…
Rob
  • 2,332
  • 7
  • 31
  • 35
47
votes
8 answers

Remove fragment in URL with JavaScript w/out causing page reload

Background: I have an HTML page which lets you expand certain content. As only small portions of the page need to be loaded for such an expansion, it's done via JavaScript, and not by directing to a new URL/ HTML page. However, as a bonus the user…
Philipp Lenssen
  • 8,818
  • 13
  • 56
  • 77
46
votes
4 answers

Encoding of window.location.hash

Does window.location.hash contain the encoded or decoded representation of the url part? When I open the same url (http://localhost/something/#%C3%BC where %C3%BCtranslates to ü) in Firefox 3.5 and Internet Explorer 8, I get different values for…
Michael
  • 8,920
  • 3
  • 38
  • 56
39
votes
9 answers

What are the differences between history.pushState & location.hash?

I want to update the URL using window.location.hash or history.pushState. What are the differences and advantages of each method?
Krueger
  • 1,178
  • 3
  • 11
  • 26
37
votes
3 answers

What are fragment URLs and why to use them?

I am new to PHP Development. Today I came across the interesting topic of URL fragments, specifically the # part of URLs. I searched and found that it's like www.example.com/foo.html#bar But I don't understand why this #bar is needed. Or how to…
Nilesh
  • 884
  • 3
  • 11
  • 22
33
votes
3 answers

Why does Twitter use a hash and exclamation mark in URLs, and how do they rewrite search URLs?

We understand the hash is for AJAX searches, but the exclamation mark? Anyone know? Also, the "action" attribute for their search form points to "/search," but when you conduct a search, the hash exclamation mark appears in the URL. Are they…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
31
votes
7 answers

How to show Ajax requests in URL?

What I want is to have links which change a part of the page , and a dynamic URL for it, where I can specify variables such like #calendar=10_2010tabview=tab2 Check this for an exact example: CLICK HERE FOR EXACT DEMO So here is the link format what…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
31
votes
3 answers

Maximum length of URL fragments (hash)

Is there a length limit for the fragment part of an URL (also known as the hash)?
Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297
30
votes
2 answers

Smooth scroll to anchor after loading new page

I want to navigate to an anchor point on a new page, but I want the page to load at the top then immediately smooth scroll to the relevant anchor point. Can this be done? I am a complete newbie with Javascript. This is the js I currently use for…
Mr Toad
  • 202
  • 2
  • 12
  • 41
1
2
3
16 17