views:

240

answers:

1

Specifically, I'm looking to mimic back button behavior with AJAX, and I don't want to attach #uglyhashes to every URL, which seems to be the standard practice of most solutions I've seen.

(For what it's worth, I'm perfectly fine with a solution that does not work at all in IE. :P )

+3  A: 

You can attach a listener to the document's 'DOMContentLoaded' event to fire javascript when the page loads. This should fire when going back and forward as well as when the page initially loads. How you use that javascript to implement the behavior you want is up to you -- the way most people handle is with the "#uglyhashes".

Edited to add example code for Mozilla (and to update event name):

document.addEventListener("DOMContentLoaded", function() {
   // Do watchya like
},false);
John