Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Out of curiosity, why would one set window.location.hash?


In order to maintain the usability of the URL in a heavily AJAX application.

For example, with movielandmarks I designed it so that you don't use back/forward at all. But I wanted to provide a useful URL for bookmarking and sharing with friends. So I used the hash for this because changing the actual URL of the page forces a refresh.


To save some state of your JS application which can be saved to bookmarks (or copy-pasted to someone else). For example, Gmail adds "#sent/12aa04feebaac50e" when I open an e-mail I just sent. Also, to get the "back" button to work properly in JS applications.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: