AJAX: Notes on Detecting History Changes in Safari

I've been experimenting with how to get back and forward buttons and bookmarkability for AJAX apps in Safari. 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. Here are some of my notes from playing around today with Safari at a rental shop:
  • 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.

Comments

Popular Posts