Created
January 13, 2016 15:48
-
-
Save kraftbj/8f41d351221534a25630 to your computer and use it in GitHub Desktop.
pushstate listener to grab when IS changes URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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