If you set the event listener in load, getElementsByTagName will not take the iframe element.
What should I do?iframeDoc is a global variable.
window.addEventListener('load', async function(){
let iframeBody = document.getElementsByTagName('iframe')[0].contentDocument.body;
observer.observe (iframeBody, config);
});
Because the js file was loaded in iframe, the document itself pointed to the document in iframe.So I was looking for an iframe in iframe that does not exist in the above code.
—— From Comments
That's right.
© 2024 OneMinuteCode. All rights reserved.