0

Is there any way to disable console error in browsers. I have tried by replacing th built in function with empty methods.

function disableConsole() {

console.log =
console.error =
console.info =
console.debug =
console.warn =
console.trace =
console.dir =
console.dirxml =
console.group =
console.groupEnd =
console.time =
console.firebug =
console.exception =
console.table =
console.timeEnd =
console.assert =
console.profile = function () {
};
window.console = console;

}

But the above code doesnt remove console errors from the browser,

eg : status 404 in getting a resource etc.

ArUn
  • 1,317
  • 2
  • 23
  • 39

1 Answers1

0

that's probably because an exception is thrown. you could try to wrap ALL of your code with try {} catch {} ? and then swallow the error..

Dennis Dam
  • 53
  • 1
  • 7
  • The console errors are from the html. the binded image may be not found. Also am writing base href dynamically to html by ` document.write("");` which is also causing errors in console – ArUn Mar 09 '17 at 09:24
  • hmm seems there is no solution (see [link](http://stackoverflow.com/questions/9893886/prevent-image-load-errors-going-to-the-javascript-console) ) .. only way I can think of is to set the src attribute from javascript, and first load the image in javascript to check if it exists... – Dennis Dam Mar 09 '17 at 09:35