Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created September 16, 2010 00:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowboy/581734 to your computer and use it in GitHub Desktop.
Save cowboy/581734 to your computer and use it in GitHub Desktop.
How does IE6/7 "back button" support work?
// From http://a5.twimg.com/a/1284588078/javascripts/phoenix.bundle.js
(function (B) {
var A = (function () {
var E = {
select: "input",
change: "input",
submit: "form",
reset: "form",
error: "img",
load: "img",
abort: "img"
},
C = {};
function D(F, I) {
var H = (arguments.length == 1);
if (H && C[F]) {
return C[F]
}
I = I || document.createElement(E[F] || "div");
F = "on" + F;
var G = (F in I);
if (!G && I.setAttribute) {
I.setAttribute(F, "return;");
G = typeof I[F] == "function"
}
I = null;
return H ? (C[F] = G) : G
}
return D
})();
B.fn.hashchange = function (D) {
if (A("hashchange", window) && (document.documentMode === undefined || document.documentMode > 7)) {
this.bind("hashchange", D)
} else {
var C = location.hash;
setInterval(function () {
if (C !== location.hash) {
D(B.Event("hashchange"));
C = location.hash
}
}, 250)
}
return this
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment