I am trying to make use of the hash symbol to enable back-button and refresh functionality in my AJAX web app.
In Firefox and Chrome when I click refresh the browser reloads everything properly and when the script below is run a new request is made using the URL that appears after the # sign.
In IE8 the request is never made during a refresh, however the alert pops up as if it has! I can reproduce this behavior in this simplified HTML document which I posted here:
Full HTML Doc http://pastebin.com/CVySwtup
Sample Code
$(document).ready(function () {
// 1. AJAX history & back button
$(window).bind("hashchange", function (e) {
if (!ignoreHashChange) {
// Load content
$("#content").load(location.hash.substring(1), function () {
alert("content loaded!");
});
}
ignoreHashChange = false;
});
// 2. Home page / refresh action
if (location.hash) {
$(window).trigger("hashchange");
} else {
location.hash = "Customers/List";
}
});
edit: same behavior in IE8 when using $.get()