Skip to content

Instantly share code, notes, and snippets.

@kraftbj
Created January 13, 2016 15:48
Show Gist options
  • Save kraftbj/8f41d351221534a25630 to your computer and use it in GitHub Desktop.
Save kraftbj/8f41d351221534a25630 to your computer and use it in GitHub Desktop.
pushstate listener to grab when IS changes URL
function pushStateListener() {
var pushState = history.pushState;
history.pushState = function() {
pushState.apply(history, arguments);
$(window).trigger('pushState');
};
$(window).on('pushState', function() {
alert(String(window.location).match(/.+\/(\d+)(?=\/$)/)[1]);
//Returns page number
});
}
pushStateListener();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment