I am building an app that has a section that displays news. Every news item has a preview button, that displays the source of an iframe. All good, until I see that some news pages are console.log a lot. I have successfully turned off console.log for my app, but not for the iframe.
I have tried the following, but it's not working for my case:
const iFrameRef = React.useRef();
React.useEffect(() => {
if(iFrameRef.current){
const iframeWindow = iFrameRef.contentDocument;
iframeWindow.console.log = function() { };
}
}, [iFrameRef]);
<iframe ref={iFrameRef} src={source} id="iFramePreview" />
What is the method to turn off console.log for an iframe?