Executes js code after redirect to another url

前端 未结 1 746
慢半拍i
慢半拍i 2020-12-20 06:15

I have a page as below, when user clicks the Go href, it will redirect to another page. I want to do some JS manipulations on the redirected page after the page is fully loa

相关标签:
1条回答
  • 2020-12-20 06:53

    You can't run JavaScript after you've destroyed the environment it runs in. Leaving a page will destroy that environment.

    The only ways to do this would be to:

    • load the new page in a frame (and the new page would have to be on the same origin) and then access it using the frames API.
    • pass some information to the server hosting the new page (e.g. via the query string) and read that to determine if the JS should run or not
    0 讨论(0)
提交回复
热议问题