[英]MutationObserver div change src
我想知道,我在htm頁面(1)中有一個div,該div打開並顯示另一個htm文件(2)。 我在此頁面上有區域(2)。 當我單擊這些區域時,它將在div中打開另一個頁面。
我想知道原生JS中是否有一種使用MutationObserver的方法來觀察這種修改並在每次發生時都做些什么?
我專門在IE11上工作。
第1頁:
<div id="one">
<iframe src="index.htm" style="width:100%; height:100%;" alt="" id="fram"> </iframe>
</div>
索引
<img src="../assets/SM2.png" usemap="#Tr" id="draggable" class="dragme" onload="initiate()">
<map name="Tr" style="z-index=1;" id="mapping">
<area title="2" shape="circle" coords="6426,4171,8" href="2/Tr.xml">
...
當我單擊Index.htm中的區域時,事情就會發生。
我在互聯網上找不到解決方案,因為這是一個非常特殊的問題/:
提前致謝!
祝你有個美好的夜晚!
編輯1:是否可以通過使用“ OnPropertyChange”之類的可怕方式來實現,並且當我單擊該區域時,我調用了一個可更改頁面中某些屬性的函數? :/
好吧,我將其發布為答案:
您只需在iframe
上監聽load
事件,因為每次(新)頁面加載完成時都應觸發該事件:
document.getElementById('fram').addEventListener('load', function()
{
/* this is called on the iframe's first load,
and every time it has finished loading a new page */
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.