Skip to content

Instantly share code, notes, and snippets.

@sdougbrown
Created July 6, 2016 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdougbrown/16e0a61febae13793fcb99ed865c5e26 to your computer and use it in GitHub Desktop.
Save sdougbrown/16e0a61febae13793fcb99ed865c5e26 to your computer and use it in GitHub Desktop.
(function () {
var CHECK_INTERVAL = 100;
var CURRENT_PATH = window.location.pathname;
var PREVIOUS_PATH = "";
function checkPath () {
if (CURRENT_PATH !== window.location.pathname) {
PREVIOUS_PATH = CURRENT_PATH;
CURRENT_PATH = window.location.pathname;
$(window.location).trigger("change", {
currentPath: CURRENT_PATH,
previousPath: PREVIOUS_PATH
});
}
}
// poll for location changes
setInterval(checkPath, CHECK_INTERVAL);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment