最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get the new URL on window.popstate - Stack Overflow

programmeradmin4浏览0评论

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
})

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
})
Share Improve this question asked Sep 15, 2016 at 5:15 user6459745user6459745 2
  • Doesn't location.href work? – Alexander O'Mara Commented Sep 15, 2016 at 5:17
  • window.location.href.toString().split(window.location.host)[‌​1] – Vasim Shaikh Commented Sep 15, 2016 at 5:20
Add a comment  | 

1 Answer 1

Reset to default 23

Use this

window.onpopstate = function (){
    newPageUrl = location.href;
}
发布评论

评论列表(0)

  1. 暂无评论