.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.