[英]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.