Solved

Window.Onerror=NULL for Internet Explorer

Posted on 1998-04-04
4
1,270 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

937 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now