Usage of Hash(#) in URL

2019-01-13 17:00发布

I was wondering is there any use of hash other than as an anchor in URL. I read about it here getting the full url including query string after hash . What is state information for the client? Please help.

2条回答
走好不送
2楼-- · 2019-01-13 17:25

The hash can be used also for single page applications, so instead of using it to navigate to a point in a page you use the hash as a means for navigated from page to page. The advantage of this is that it does not require a page refresh.

There is also a method called hashbanging which is used for single page applications and is used for helping ajax applications more indexible.

There are a few good articles on the subject

查看更多
forever°为你锁心
3楼-- · 2019-01-13 17:38

Consider one page website, or website built fully on AJAX, without any page reloads.

#hash helps such applications to push state of the application to the client, this helps the application itself to be aware of the state and the client (and browser) to be aware of the state. This will also help the user to bookmark the application in its' current state and use back and forward buttons (browser history).

查看更多
登录 后发表回答