Web 2.woes
July 12, 2010

I've recently begun working on a suite of web services for social sites (MySpace, Facebook, Orkut). You can check out my progress at services.tolleycoder.com. I'll probably change the name and move it to its own domain when its ready for prime time, but its good where it's at for the time being.

So, my idea for this is to take advantage of all the skills I've been teaching myself recently and come up with something really snazzy. Last night I was on gmail and I noticed that it was using the location.hash property as I navigated around. Not only that, but the back and forward button worked as well. This got me thinking. If I implemented a similar solution, I could have the browser keep track of its own history, just like it normally does, while still using AJAX to make every request.

I had been using a hidden iframe who's document had an onload event which loaded a second page, who's onload event told the parent window to fire off an 'onBackButton' event (using mootools events.) This allowed my application code to hook into back button events and I was able to simulate the back button, but the forward button, that was a different story. This also meant that I had to keep track of the history of the application either in javascript on the client, or on the server in the session. Keeping track of the history yourself is a pain.

I spent some time today googling around and I found out about a method that uses location.hash and a polling system to keep track of where the page is. All you have to do is change location.hash to reflect your current page. So far so good, but the problem comes when you try to throw IE into the mix. Turns out that IE doesn't add a layer to the history stack when you change a fragment of the URL. You can however put a hidden iframe in the document and use it's source property like the location.hash.

So, I'll be spending most of my night tonight implementing a system that works in both IE and standards compliant browsers. Its a pain, but I'll be thrilled when its finally complete.


Home