4

I have a javascript code trying to reach for an image resource. sometimes the image exist and sometimes it doesnt (not on the domain, the domain doesnt exist and more).

<script>
    var img = new Image();
    img.src = 'http://notexistdomain1.com/myimage.png';
    img.onerror = function () {
        console.log('not found!');
    };
    img.onload = function (ev) {
        console.log(':)', ev.status);
    };
</script>

I would like to hide chrome errors from being displayed on console and network: enter image description here enter image description here

Using javascript. is that possible?

Ben Diamant
  • 6,186
  • 4
  • 35
  • 50

1 Answers1

0

No, it's not possible if you want to auto-disable the errors via javascript.
The possible interactions, directly with the browser, are limited for security reasons (see Chrome Javascript API).

If you just want to disable the error-log in your browser, see: Can I prevent the Chrome Developer Tools console from logging image 404 errors?

Community
  • 1
  • 1
patrickkeller
  • 1,236
  • 2
  • 11
  • 20