Solved

Window.Onerror=NULL for Internet Explorer

Posted on 1998-04-04
4
1,276 Views
Last Modified: 2012-06-27
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
Comment
Question by:ljaques
  • 2
4 Comments
 
LVL 2

Expert Comment

by:cyberwizz
ID: 1279045
Sorry there's no way to do it. You will just have to test your code on all the neccessary browsers.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 1279046
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
 

Expert Comment

by:rafam
ID: 1279047
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
 

Expert Comment

by:rafam
ID: 1279048
Sorry, I forgot something...

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

function handleError {return true;}
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question