Use it like that:
var parent=document.getElementById(parentID);
otherwise parent will be global, but there always is a global parent-object, the parent window(and it is read-only).
Furthermore:
IE requires as 2nd argument a valid node or null, so be sure that parent has childNodes to avoid errors:
parent.insertBefore(child,(parent.hasChildNodes())
? parent.childNodes[0]
: null);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…