Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between a querystring and a fragment?

When using jQuery BBQ they are using the words "querystring" and "fragment".

What is the difference btween the two?

like image 961
ajsie Avatar asked Dec 24 '09 02:12

ajsie


1 Answers

In the definition of a URL (see e.g. here):

Fragment URLs

The URL specification en vigeur at the writing of this document ([RFC1738]) offers a mechanism to refer to a resource, but not to a location within a resource. The Web community has adopted a convention called "fragment URLs" to refer to anchors within an HTML document. A fragment URL ends with "#" followed by an anchor identifier. For instance, here is a fragment URL pointing to an anchor named section_2:

http://somesite.com/html/top.html#section_2

The #section_2 part is also called "the fragment". Its interpretation is up to the user agent (AKA client AKA browser), though the universal convention is that it's the anchor of an <a> tag to which the browser is asked to position itself.

The Query String, as explained here, is the part of the URL that's passed to the server-side program -- normally after a ? and up to but excluding the # if any. So, in:

http://server/path/program?query_string#thefrag

the query string would be query_string and the fragment would be thefrag.

like image 170
Alex Martelli Avatar answered Oct 20 '22 06:10

Alex Martelli