[英]How to trigger a function when iframe src change?
我有像http://remote-domain.com/
src iframe,当src被更改时,我需要触发像iframeSrcChanged()
这样的函数
<iframe id="iframe" src="http://remote-domain.com/" frameborder="0" width="100%" height="100%" ></iframe>
当用户在iframe中点击about-us时,iframe src会变为
<iframe id="iframe" src="http://remote-domain.com/about-us.html" frameborder="0" width="100%" height="100%" ></iframe>
所以这次我需要触发iframeSrcChanged()
函数。
请帮我解决这个问题。
var iframe = document.getElementById("iframe");
iframe.addEventListener("DOMAttrModified", function(event) {
if (event.attrName == "src") {
// The "src" attribute changed
}
});
但是,这仅适用于现代浏览器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.