javascriptpopstate

Get the new URL on window.popstate


Is there any way I can get the new page's url when the window.popstate is fired?

window.onpopstate(function (){
    newPageUrl = //get the new page's URL
})

Solution

  • Use this

    window.onpopstate = function (){
        newPageUrl = location.href;
    }