javascript - 使用 javascript (jquery) 找出 iframe 的 window.location.href 何时发生更改

标签 javascript jquery events iframe location-href

这个问题确实概括了......

我有一个带有子 iframe 的父页面,

如何知道 iframe 的位置何时发生变化,即用户单击了 iframe 中的链接并且 iframe 正在导航到另一个页面

我知道我可以像这样绑定(bind)到 iframe 的 onload 事件

$("#theIframe").load(function(){
  //Do something
}) 

但那时已经太晚了...页面已经加载...

基本上,我需要在单击链接或提交表单后立即查明,或者任何导致 iframe 位置发生更改的原因...

它不必在 IE 中工作,但如果能在 IE 中工作就更好了...而且它也不必是 jquery...

提前致谢...

最佳答案

尝试

onbeforeunload

子文档正文上的事件。所有主流浏览器都支持它。

关于javascript - 使用 javascript (jquery) 找出 iframe 的 window.location.href 何时发生更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1956328/

相关文章:

jquery - 将 json 文件中的数据加载到引导表中

JQuery - 无法按类选择动态创建的 URL 标记

jquery - 在移动 View 而不是桌面 View 中制作响应式 slider

php - DDD : Should I use the Symfony EventDispatcher for my domain events?

javascript - subview 更改事件未触发

javascript - jQuery:触发器不会在使用 .load() 加载的元素上触发

javascript - 通过将 HTML 元素附加到 URL 来定位页面的特定部分

javascript - 用于 JavaScript 生成的内容的 Python Web 抓取

javascript - Angular 4 : Cannot instantiate cyclic dependency! InjectionToken_HTTP_INTERCEPTORS

javascript - 更改使用 Three.js 创建的 3D "Cube"的 Angular