Solved

Window.Onerror=NULL for Internet Explorer

Posted on 1998-04-04
4
1,287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

732 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