I'm a comp sci student right now so I haven't had too much trouble teaching myself javascript, but I'm learning on my own so I'm sure I'm missing something simple. Advice would be much appreciated.


I'm working on a site that updates text dynamically via javascript when navigation is used rather than reloading to a new page. I've got the links all set up right, but when you refresh the page the content is reset to the home content.

To fix this, I'm trying to change the hash whenever the content updates and then read the hash when the page loads and update the content appropriately so users can refresh the page or bookmark certain content without problem.

The problem comes when I try to update the hash. I have a simple algorithm that generates an appropriate hash given the current content on the page. When I do

window.location.hash = myHash;
it works fine unless the URL is set to
with nothing after the hash mark. in that case when the hash is updated, i get
which of course effectively crashes the page.

If it makes a difference, I'm still developing locally so myurl is an address on my machine.