TensE
TensE

Reputation: 49

Block cross-domain iframe console logging

I'm making a page that has multiple iFrames that show reports. The reports generate a ton of console output which contributes to the page taking up more memory.

I tried to do the workaround with

console.log = function() {}

As well as a couple others I found, but none of them work. Majority of the errors are "Failed to load resource" and failed GET requests. I'm wondering if there's a way to maybe filter just those out.

Again the issue is that all the iFrames are cross domain and I have 0 access to the source.

Upvotes: 1

Views: 1028

Answers (2)

razorRun
razorRun

Reputation: 110

Try it like this

    iframeWindow.console.log = function() { /* nop */ };

This works on Mozilla,Chrome

Upvotes: 0

user149341
user149341

Reputation:

Failed requests and other browser errors are logged by the browser internally, not through console.log. There is no way for your page to filter them out. If you don't want to see them, don't look at the console.

Upvotes: 1

Related Questions