binding popstate event not working binding popstate event not working google-chrome google-chrome

binding popstate event not working


Type this into the console

window.onpopstate = function() {alert(1);}; history.pushState({}, '');

then click the back button.


I prefer adding the popstate listener as follows, to prevent overwriting of what's already in window.onpopstate:

window.addEventListener('popstate', function(){alert(1);});