check for onpopstate in window instead of window.onpopstate