Questions tagged [url-fragment]

URL fragments are the part of the URL that appears after the hash(#) character. Fragments are never sent to the server as part of the URL request. Use with the [url] tag.

In URLs, a fragment is what appears after the # character

https://www.example.com/directory?query_string#url_hash

Fragments were originally used to force a browser to scroll to a specific id. For instance https://www.example.com#scroll-to-me would scroll to the div below in an document

<div id="scroll-to-me">Some content</div>

As browsers create a history event every time the hash changes, the URL fragment has become a programming tool unto itself. This data is not sent from the client to the server, however, so if you want to store data there, or interact with it, you must use .

See also

32 questions
239
votes
8 answers

How do I get the fragment identifier (value after hash #) from a URL?

Example: www.site.com/index.php#hello Using jQuery, I want to put the value hello in a variable: var type = …
cppit
  • 4,478
  • 11
  • 43
  • 68
188
votes
5 answers

Proper URL forming with a query string and an anchor hashtag

When both a query string and anchor tag (hash tag) are visible in a URL, what is the proper order for them to appear? http://www.whatever.com?var=val#anchor or http://www.whatever.com#anchor?var=val Is there any documentation on this? The URLs are…
Dan
  • 3,750
  • 5
  • 24
  • 38
130
votes
10 answers

Get fragment (value after hash '#') from a URL

How can i select the fragment after the '#' symbol in my URL using PHP? The result that i want is "photo45". This is an example URL: http://example.com/site/gallery/1#photo45
ilija veselica
  • 9,414
  • 39
  • 93
  • 147
22
votes
0 answers

What does colon tilde colon (:~:) mean in URL hash fragment?

Recently, I noticed that sometimes when I search on Google, Google can highlight the relevant part of the webpage by attaching a hash fragment like…
zypA13510
  • 1,092
  • 1
  • 10
  • 28
15
votes
2 answers

How to detect change in the URL hash in Next.js?

How do we detect a change in the URL hash of a Next.js project? I don't want to reload my page every time the slug changes. I cannot use since all of my data comes from DB Example: When clicking on an tag from http://example/test#url1 to…
Appu Rajendran
  • 192
  • 1
  • 2
  • 10
3
votes
1 answer

Javafx getHostServices().showDocument not working when url includes fragments for local files

Im working on a javafx app and a requirement is that on clicking a hyperlink, it opens the given url in the browser. I have this working with the following url = "files/file.html"; getHostServices().showDocument(url); However, when the url includes…
Awk11
  • 63
  • 5
3
votes
3 answers

Regex to match specific URL fragment and not all other URL possibilities

I have - let say - example.com website and there I have account page. It may have GET parameters, which is also considered part of account page. It also may have URL fragment. If it's home.html fragment - it is still the account page. And if another…
pesho hristov
  • 1,946
  • 1
  • 25
  • 43
3
votes
1 answer

Escaped # in URLs, sitemap and handling by Google crawler

We have a large set of URLs of which some contain a hash character. The hash is not to indicate a fragment, but part of the URL path, so we escape the hash by %23, e.g. http://example.com/example%231 http://example.com/another-example%232 … Our…
qqilihq
  • 10,794
  • 7
  • 48
  • 89
2
votes
2 answers

Scrapy : (400 Bad Request)HTTP status code is not handled or not allowed

As i am new to python and scrapy. I have been trying to scrape a website which is URL-fragmented. I am making a post request to get the response but unfortunately its not getting me the result. def start_requests(self): try: form =…
1
vote
1 answer

How to highlight active fragment link?

I've a navigation bar that scrolls to the page's sections using fragments, e.g: // nav {'Development'} // somewhere else in the page {'Development'} How do I apply a style to the navigation link…
User
  • 31,811
  • 40
  • 131
  • 232
1
vote
1 answer

Is there a standard or preferred tag type for adding additional anchor / fragment links to a location?

I currently have an id attribute on each section heading in a HTML document, so that URLs can be generated with a hash fragment that links directly to that section in the document. For example:

Section 3.4 - Foo

This would,…
Polynomial
  • 27,674
  • 12
  • 80
  • 107
1
vote
1 answer

Linking to text fragment with element ID fallback

I would like to link to a text fragment, like so: https://pvk.ca/Blog/2019/01/09/preemption-is-gc-for-memory-reordering/#event-counts-with-x86-tso-and-futexes:~:text=However%2C%20if%20we%20go This link1 has a fragment as…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
1
vote
1 answer

How to get the "fragment" part of an url in a nuxt middleware?

I want to get the access_token in the url after a redirection from AWS COGNITO in a "implicit" oauth flow. AWS Cognito redirect the browser to : https://mydomain/#access_token=xxxxx I want to get the "access_token=xxxxx" part for storage, in a nuxt…
David Vergison
  • 35
  • 1
  • 10
1
vote
0 answers

Is there any official formatting for the URL fragment?

In the project I'm working on part the URL fragment is used to update the view. But if the view is updated by the URL fragment the vertical anchor position is lost. Is there an official way to format a URL fragment to contain a view and anchor? Or…
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
1
vote
2 answers

HTML fragment links work with CSS positioning?

Last night I decided to add HTML fragment links in my computer listing page. However, no matter the pattern of linking, or whichever browser I use, those fragment links are simply not…
icelava
  • 9,787
  • 7
  • 52
  • 74
1
2 3