Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER)

You might see this exception in Firebug from time to time. As I've found very little information about what may cause this, and was forced to debug some obscure piece of code for hours to get to the problem, I thought I'd post a possible cause of this exception.

.insertBefore() can throw this exception if what you try to insert is undefined, as in the following example:


<html>
<body>
<div id="hello">Hello</div>
<script type="text/javascript">
function returnundef(){ return; }
document.body.insertBefore(
returnundef(),
document.getElementById('hello')
);
</script>
</body>
</html>


Note: IE will give a "Type mismatch" error in this case.

Strangely, you get a simple "VAR not defined" error both in IE and Firefox if you use an undefined variable.

Popular Posts