After attach a mutation observer inside the iframe, does pressing the <a href=''>
button inside the iframe remove the mutation observer?
I wrote the code to allow the mutation observer to detect changes of the body element, but it doesn't detect. I wonder if I wrote the wrong code or if what I thought above is correct.
If the mutation observer is deleted, should I register the mutation observer with the parent frame to which the iframe belongs?
let config = { attributes: true, childList: true, subtree: true, characterData: false };
let htmlBody = document.querySelector('body');
let observer = new MutationObserver(function(mutations, observer) {
mutations.forEach(function(mutation) {
console.log("Mutation calling");
});
});
observer.observe(htmlBody, config);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…