@lottie
If you want to catch a log from the console of an iframe, you will need to access the contentWindow of the iframe and then add an event listener for the console.log function. Here is a step-by-step guide on how to do this:
1
|
const iframe = document.querySelector('iframe'); |
1
|
const iframeWindow = iframe.contentWindow; |
1 2 3 4 |
iframeWindow.console.log = function(message) { // Handle the log message here console.log('Log from iframe:', message); } |
Now, any logs from the console within the iframe will be caught by this event listener and can be handled as needed in the parent document.