是否可以在window.location加载新URL后调用函数? [英] Is is possible to call a function after window.location has loaded new URL?

查看:588
本文介绍了是否可以在window.location加载新URL后调用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦window.location完成加载URL,我希望能够调用jquery函数。这可能吗?我似乎无法在网上找到任何关于此的信息。

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.

例如:

if(parseInt(msg.status)==1) {
    window.location=msg.txt;
    alert("This URL has finished loading")
}

谢谢,
-Paul

Thanks, -Paul

推荐答案

您可以使用 window.onload (如果您有权修改该页面的代码),或者您可以使用 window.onunload 在卸载当前页面时启动警报。加载新页面后,您无法在当前页面上执行代码。

You can either use window.onload of the destination page (if you have access to modify the code of that page), or you can use window.onunload to have the alert be launched when unloading the current page. You cannot execute code on the current page after the new page has been loaded.

这篇关于是否可以在window.location加载新URL后调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆