The right to swing my fist ends where the other man's nose begins. Oliver Wendell Holmes (1841-1935)

Disable Javascript Errors

This simple script will prevent javascript errors from being displayed in your visitor's browser

<script type="text/javascript">
function noError(){
return true;
}
window.onerror = noError;

</script>

The functionality is very simple: create a function that always returns true, and then whenever an error occurs, call this function (returning true and suppressing the error).

Shamefully, this script is only tested in IE.

21.02.2007. 19:08

Chris Cowling said on 05.10.2007. 02:11

Works like a charm, thanks!

Jeff said on 23.01.2008. 20:23

This rocks, thanks!

Tugacari said on 03.05.2008. 23:51

tks dude !

mantosz said on 13.07.2008. 10:43

an instant charm. thanks so much!

Ahmed Moussa said on 28.07.2008. 09:51

you are the Man, you save me alot of time, thanks alot.

Abhishek said on 11.08.2008. 11:54

Really great!!

Hugo Decosta said on 18.09.2008. 12:14

Pretty good! IE kills me with those warnings, some time without reason. Thanks!

savan said on 03.12.2008. 07:09

Really superb,thanks

hamed said on 20.02.2009. 05:30

thanu thanku
thanu thanku
thanu thanku
thanu thanku !!

Laxman said on 08.03.2009. 05:32

Thank you...

Satish said on 01.04.2009. 06:12

great tool. thanks.

denns said on 08.04.2009. 04:56

this actually does not work in IE7... tried and it failed :(

DavidCK said on 19.05.2009. 23:01

THANKS!! Awesome

jtan said on 25.09.2009. 08:22

yo're the man dude, thanks

Kered said on 18.12.2009. 17:24

well I must say this a great.

Well Done !!!!!!

Hermit said on 21.01.2010. 22:01

Thanks!

Lu said on 26.01.2010. 07:32

IE please go away! Until then thanks to people like you.

nithiyalakhsmi said on 26.02.2010. 11:56

Many Thanks! This script gives end to my script problem in ie6.

Martin said on 04.03.2010. 16:24

Awesome tiny script!

Thanks

ASIF MEHMOOD said on 16.04.2010. 08:36

Well done dear! its fine.
Bundle of
Thanxxxxxxxxxxxxxxxxxxxxxxxxxx.

toty said on 27.04.2010. 05:33

thank a lot for help Great...! :-)

Bryant said on 07.05.2010. 08:34

To bad i didnt see this sooner, would have saved me headaches in the past. IE seems to trip out over jQuery stuff, so i can't even make it go away most of the time.

gabriele said on 25.05.2010. 09:22

Really great!!
you have solved a big problem!!!
thanks a lot!!

Avo said on 08.07.2010. 10:18

is this inserted in the head after the scripts? or simply at the footer just before the body?

Murukesh K V said on 28.07.2010. 10:40

Really great and appreciable..

Thanks a lot..

aNieto2k said on 13.08.2010. 09:53

This is a bad solution for real applications, information is lost on the errors produced. Undoubtedly the best option is always to use a proper error handling.


try {
...
} Catch (e) {
...
}

Richard said on 28.09.2010. 12:49

Amazing - this has been bugging me for weeks 'cos the error icon looks so unprofessional even if everything else is fixed.

Barry de Rond said on 15.11.2010. 13:14

Like aNieto2k already said, this is bad practice, invest time in correct coding/programming instead of suppressing errors like this.

This is quite the same as; when you got a hole in your pants, just paint your skin dark right under it so nobody sees it.

Paul said on 13.02.2011. 19:50

Quite ashamed that I need this script, in my case the error is a scripting conflict, howeve all scripts were playing nice together regardless of the error so I thought "What the hell..." Thanks for this life-saving bit of code :)

Srikanth said on 20.04.2011. 06:24

This is the best solution I had for javascript errors. Thanks a lot ...!!!

Stephanie Shaul said on 25.04.2011. 23:25

Ok, so for us "non-tech savvy" types..... just what do I do?

Where do I type this?

As I fill out forms and registrations DAILY, this has been a nightmare for me....I can't use my computer to register anyone anymore!

Zigzag said on 29.05.2011. 02:21

Thanks :)

nadim said on 21.06.2011. 11:17

@aNieto2k and @Barry de Rond : Yes sure what you guys said are best practice when coding; but unfortunately we do not live in a perfect world. Nowadays we need to include libraries taken from elsewhere (therefor others implementations), e.g.

In these situations, you NEED this type of "escapes" else your page won't display in some cases; or display after a long time...

George Garchagudashvili said on 24.06.2011. 20:55

Great!
Tnx

Jocuri said on 27.06.2011. 09:11

Thanks a lot..
This is a great solution for display errors!

Jk said on 08.08.2011. 10:00

Great!
Thanks a lot...

fan said on 30.09.2011. 19:41

you save my time, thank you !!!

Who me? said on 21.11.2011. 21:26

Bad practice, but sometimes you gotta do what you gotta do!

Questions, comments, insults or praise? Have your say:

:

:

:


5 + 7 =

Articles RSS feed

Page last (manually) updated: October 14, 2011.