1

所以我的页面上有一个 iFrame。它不是动态加载的。它是 html 的一部分。我正在上传图像并在 iFrame 中显示它们。

有没有办法检测 iFrame 的内容何时发生变化。一旦 iFrame 获得新内容,我想调用一个 function()。

我四处搜索,答案似乎与加载新的 iFrame 或更改“src”有关。我不想做这两件事。

iframe 没有“src”,并且必须是起始 html 的一部分。

我试过'onchange','onhaschange'等......

多谢你们。

4

1 回答 1

4

There is a event fired when the iframe loads new content, jQuery makes listening to it painless:

$('iframe#yourId').load(function() {
    yourFunction();
});

Source: iframe contents change event?

于 2013-07-29T23:02:25.823 回答