Is is possible to call a function after [removed] has loaded new URL?

后端 未结 4 1015
一整个雨季
一整个雨季 2020-12-04 02:03

I\'d like to be able to call a jquery function once window.location has completed loading a URL. Is this possible? I can\'t seem to find anything online about this.

<
4条回答
  •  死守一世寂寞
    2020-12-04 02:37

    Iframe

    One (ugly) method you could use is to instead of using window.location, clearing the body, adding an iframe with the relevant path and listening to its onload function. After that you can run code inside the iframe as long as it's not cross-site scripting.

    I use this method to perform small automated scripts, that can't really on third-party plugins.


    Ajax

    Another method might be using ajax to load the page/body content. Then replacing your body with the newly loaded body and start executing the next functions.

提交回复
热议问题