Solved

Window.Onerror=NULL for Internet Explorer

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

757 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

18 Experts available now in Live!

Get 1:1 Help Now