Friday, August 19th, 2005

Notes on Detecting History Changes in Safari

Category: Editorial

Brad Neuberg saw that “no one has been able to get Safari to work with any known hack for detecting if the user has touched the back or forward buttons in an AJAX app, or getting bookmarkability to work.”

He decided to dig deep and found:

  • You can indeed see through document.location.href and document.location.hash that there is a hash value, such as “#helloworld”. However, if you change the browser location with a hash, such as “document.location.href = ‘#helloworld'”, you have to have a timeout of about 200 milliseconds to see the change (i.e. if you immediately call alert(document.location.href) right after changing the location you won’t see the change).
  • iframes and programmatic anchor changes are not in the history; however, if I create real links on the pages with anchors in them and click these with a mouse then they ARE in the history.
  • Dynamically writing into an iframe (i.e. myIframe.contentDocument.write) is NOT in the history
  • I’ve been experimenting with framesets to see how they behave in Safari for AJAX history and bookmarks. If I have two frames, where one is hidden, and change its location with a hash, then the history is recorded BUT hitting the back and forward buttons doesn’t change the address in the hidden frame. HOWEVER, if I change the search value (i.e. document.location.search) then it IS saved in history AND changes with the back and forward buttons! Even better, this works from programmatic control (i.e. I am changing these values programmatically rather than through a user clicking on actual hyperlinks).
  • Wierdly enough, now I’m NOT getting the behavior above in Safari, so frames don’t seem to hold their history…. sigh… Safari sucks.

Safari is a nice browser, but man I wish they chose Gecko over khtml, and they added their innovations on that side of the fence :)

Posted by Dion Almaer at 10:15 am
Comment here

+++--
3 rating from 5 votes

Comments Here »

Comments feed

Leave a comment

You must be logged in to post a comment.