My page is using iframes to display some content, but right now I'm working on the main page and the output from the iframes is cluttering my console and making it hard to debug. Is there any way to silence the console?
I tried setting the console to a no-op:
var CONSOLE_LOG = window.console.log;
window.console.log = function() { /* nop */ };
function LOG(msg)
{
window.console.log = CONSOLE_LOG;
console.log(msg);
window.console.log = function() { /* nop */ };
}
I expected this to work, but the iframes still generate output.
a working fiddle here
var iframe = document.createElement('iframe');
iframe.setAttribute("src", "yourIframeURL");
document.body.appendChild(iframe);
iframeWindow = iframe.contentWindow;
iframeWindow.console.log = function() { /* nop */ };
This works on Mozilla,Chrome ,Safari
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With