Suppress Error Message Popup in IE

It is notorious that IE lacks of JavaScript debugging tools. When a runtime error happens, big or small, IE provides very limited information about the error. Fortunately, I found JavaScript Stacktrace. It supports all browsers. Based on that, I built a JavaScript stack trace popup to help our team better debug in this stubborn kid – IE.

window.onerror = function () {
    //JsErrorPopUp is the module for my customized popup.
    new JsErrorPopUp(printStackTrace());
}

However, we still found the IE error message icon at the status bar or the message alert box unpleasant to see. I want to suppress it. These are the 2 solutions I come up with.

Solution 1:

add try…catch, without throwing the exception in IE.

To catch all the errors, I need to wrap our entire JavaScript application with the try block.

It does not look pretty, but I still cannot convince myself that if the try/catch block will hurt performance. If you can prove try/catch makes code slow, please feel free to drop a line.

Solution 2:

Add return true; in the onerror callback.

window.onerror = function () {
	new JsErrorPopUp(printStackTrace());
	return true;
}

Simple, clean, and makes sense.

Leave a comment