Uncaught Error Iframe has not been created yet
This error occurs when you try to access or manipulate an iframe element before it has been created or loaded on the page.
To fix this error, make sure you are accessing the iframe element after it has been created and loaded. You can check if the iframe is ready by using the load event or by checking its contentDocument property. Here's an example:
const iframe = document.createElement('iframe');
// Set iframe source or other attributes
// Wait for the iframe to load
iframe.addEventListener('load', () => {
// Access or manipulate the iframe
console.log('Iframe loaded');
// Example: Access iframe's document
const iframeDocument = iframe.contentDocument;
});
// Append the iframe to the document
document.body.appendChild(iframe);
Make sure you are executing this code after the iframe element has been added to the DOM
原文地址: https://www.cveoy.top/t/topic/hHVy 著作权归作者所有。请勿转载和采集!