What is the use of # in the url

I am creating a web application and want to follow the best practices in the web industry.

I realized that many web applications use # in their url.

For example, take a look at google analytics.

https://www.google.com/analytics/web/?hl=en#report/visitors-language/a33185827w60383872p61754588/ 

This address is in the address bar when I look at the page on the visitors page.

 https://www.google.com/analytics/web/?hl=en#report/visitors-geo/a33185827w60383872p61754588/ 

This address is in the address bar when I look at the visitors geolocation page.

I understand that this is # report / visitors-language and # report / vistiors-geo

I also understand that Google Analytics uses iframes. It seems that only the main content field changes and displays the content.

Is it used to achieve iframe functionality? I would appreciate it if someone could direct me (a novice programmer trying to learn more things) in the right direction.

+4
source share
6 answers

A few answers, but none of them cover the main part.

Regular URL, your own example: https://www.google.com/analytics/web/?hl=en#report/visitors-language/a33185827w60383872p61754588/

You can think of the post-hash part (including the hash) (aka Fragment) as a client request.

The web server will never know what was entered after the hash sign. This is a browser pointing to a specific page identifier.

For basic web pages, if you enter

 < a name="main">welcome< /a> 
, and if your site is located at http://example.com/welcome , opening http://example.com/welcome#main will β€œfocus” your browser on the β€œwelcome” text in the tag.

The web server will not know if #main was in the url or not.

The contents of the URL after the question mark are called as URL parameters. The web server can provide different content for these values.

Then there is a technology called "Ajax" that uses this # part in the URL to deliver various content without loading the page. These are not iframes. Using JavaScript, you can trigger a change in the post-hash of the URL and make a request to the server to get a specific part of the page. http://example.com/welcome#main2 Even if the part with the name "main2" does not exist, you can show it using JavaScript.

Hashbang is "#!" This will make life easier for search engines by indicating that this part is a dynamic web page.

PS: They just noted that this is my 100th answer in SO!

+2
source

This is a hash in the url.

Many browsers support a hash change event in javascript.

according to my knowledge, changing a hash is a turnaround in ajax callbacks.

as such, when the user interacts with a hash link, then when the hash changes, the event is fired, and you can apply any thing with javascript.

another thing is that hash change is supported by browser history.

+3
source

see below url

SEO and use! # in url

or read it

'#! called "hashbang," and they are the root of everything that is evil in web development. "

Mostly weak web developers decided to use #anchor names as a shredded hack to get "web 2.0" to work on their page, and then complained that their pages were damaged. Google started working with their kludge by including hashbang.

Weak web developers accepted this work as the gospel. Do not use it. This is a crutch.

Web development that depends on hashbangs is web development that is not done right.

This article is much better articulated than I could ever be, and tackles the Gawker media debacle from moving to a hash-based website (unsuccessful). He tells you what is happening and why it is bad.

http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs

+1
source

Correct me if I am mistaken, the hashtag in this URL will be used as a binding to scroll the page to the element with the identifier. For example, I send you to url http://example.com/sample#example , and the page will scroll (just display) in the element (I use div as an arbitrary example, it can be anything).

0
source

Ajax and hash mark in the URL, mainly used for quick action. If you have a part of your site that can only be seen by a fire event (mainly a click), it would be difficult to share it. With the hash mark in the URL, you can (via javascript) make the browser think that you have performed the required action and it will display the corresponding part.

0
source

Usually "#" is used in the url, it will find the specific identifier that is next to the "#" on this particular page. With this, we can also view specific content in the middle of the page.

0
source

Source: https://habr.com/ru/post/1439317/


All Articles