I have a forum page that displays a tree view of the posts below the currently selected post. When you click on a message in the tree, the new message text is loaded into a div at the top of the page using AJAX, and then the following code is run:
window.location.hash = "page_top";
Of course, "page_top" is a binding element at the top of the page, so the newly loaded message body scrolls to the window.
This works great in all browsers except Safari. In Safari (tested on PC and iPhone), it only works the first time location.hash is set. If you install it again, the page will not scroll.
The end result is that the newly loaded message body does not scroll to the view in Safari, and you need to scroll back to the top of the page every time you select a new message from the tree.
Why don't Safari like it, and is there anything I can do to fix it?
Edit:
I assume this is due to an error you might find in Googling about location.hash and Safari. Safari seems to have had an error where, if you set the hash to the same value twice, this will reload the page. I assume that when they fixed this error, they corrected it too carefully and stopped doing anything when you again set the hash with the same value.
http://www.howtocreate.co.uk/safari/locationHashBug.html
source share