• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1298
  • Last Modified:

Window.Onerror=NULL for Internet Explorer

I noticed that Microsoft didn't support the standard Javascript command: window.onerror=null.

By using the command, the Javascript enabled browser will *NOT* display any form of Javascript error if any shoulf occur.  So, if a variable or function is not defined yet, the annoying default Javascript error window will not pop up and report it thanks to that onerror command.

The command works beautifully in Netscape, of course, but not in Internet Explorer 4 and most likely not in Internet Explorer 3.  Is there anything i can do to prevent the JS error window from popping up in MS Internet explorer?

Thanks a million.

0
ljaques
Asked:
ljaques
  • 2
1 Solution
 
cyberwizzCommented:
Sorry there's no way to do it. You will just have to test your code on all the neccessary browsers.
0
 
Michel PlungjanIT ExpertCommented:
According to http://www.microsoft.com/sitebuilder/archive/dhtml/dude1001.htm
MSIE 4.x should have support for the window.onerror event handler introduced in Netscape 3.0 (JavaScript 1.1)

In order not to test the browser and version, always test the availability of a
function, method or variable before using it.

It is hard work writing compatible JavaScript, but it is possible without testing the name of the browser.

An if (document.images) to test image rollover support is a lot more simple and compatible than testing the navigator object.

Hope this answered your question.

Michel

0
 
rafamCommented:
Yes, you can define a function to handle any errors:

window.onerror=handleError;

and then, if you want to do nothing just leave it blank

function handleError() {}
0
 
rafamCommented:
Sorry, I forgot something...

You have to put a 'return true' on your function.

function handleError {return true;}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now