javascript - 是否可以在 window.location 加载新 URL 后调用函数?

标签 javascript jquery

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

例如:

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

谢谢, -保罗

最佳答案

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

关于javascript - 是否可以在 window.location 加载新 URL 后调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7493847/

相关文章:

javascript - ES7 类 : Declaring Properties Outside of Constructor

javascript - 我可以使用 TLS 加密 Node.js TCP 流量以使其无法读取吗?

javascript - 尝试在 jsonp 请求完成之前读取 var

javascript - 从对象中提取图像值

javascript - bootstrap 切换复选框按钮标签由 jquery 更改

javascript - 在 jquery 中使用键链接按下

javascript - 有没有办法在 HTML5/CSS 中制作一个滚动的 "viewport"框?

jquery - 通过 chrome inspector css 查找图像的根路径

javascript - 如何更新动态表中的tablesorter onclick?

javascript - 如何在悬停时更改模式弹出窗口的字体大小