bodacydo
bodacydo

Reputation: 79339

How do #hashes work in URL schemes if they're not part of URL request?

I'm trying to figure out how the browsers handle the hashes in the url requests and the page rendering.

For example, let's say I go to www.example.com/#footer.

When I request this URL the browser makes the GET request to the www.example.com but doesn't have the #footer in the request.

When the page loads, the browser knows I asked for the #footer and jumps to that location.

What happens in the more complex situations when I do a redirect? For example, let's say I 301 redirect to www.example.com/birds/#middle. How does the browser know that it can jump to the #middle if hash is not part of the request URL?

Also how does web server know that I'm about to jump to particular anchor #hash so that it can serve content just for #hash? (Like facebook does when you go from one section to another. Only #hash anchor tag changes.)

Upvotes: 2

Views: 820

Answers (1)

Sergey Novikov
Sergey Novikov

Reputation: 644

They called anchors here is definition and examples. Once the page loaded the browser is looking for this "anchor" and moves page there if it finds it.

Upvotes: 2

Related Questions