Why
$(function () {
$(window).bind(\'popstate\', function () {alert(\'pop\');});
window.history.pushState(null, \'\', \'/foo\');
});
Document https://developer.mozilla.org/en-US/docs/Web/Events/popstate says:
Note that just calling
history.pushState()orhistory.replaceState()won't trigger a popstate event. The popstate event will been triggered by doing a browser action such as a click on the back or forward button (or callinghistory.back()orhistory.forward()in JavaScript).