Today I stumbled across a very strange IE issue. Again. Basically the code that was working fine in all real browsers – the code loaded some HTML fragment containing script tags using AJAX and added it to the page. Nothing complicated, except that those script tags require some special handling in Internet Explorer, as they do not execute automatically when being added to the page:
if(IE) {
var scripttags = NewlyAddedDomViaAjax.getElementsByTagName(“SCRIPT”);
var head = document.getElementsByTagName(“head”)[0];
for(var i=0, j=scripttags.length; i < j; i++)
{
var scripttag = document.createElement(“SCRIPT”);
scripttag.src = scripttags[i].src;
head.appendChild(scripttag);
}
}
No big magic and works fine. Except for the case that the script tag comes as first element in the newly inserted HTML code. In this case the getElementsByTagName is *not* returning the script node at all – it just returns an empty result set. This means that the JavaScript code is not executed in IE….
Luckily this problem is quite easy to solve – just move some other HTML code in front of the HTML snippet that is returned via AJAX – place all the script tags at its end and everything will work fine!
btw, how about Google? Not of great help, the closest I could find was this unanswered forum post.

“Except for the case that the script tag comes as first element in the newly inserted HTML code. ”
You rock. I had this problem and was unable to find any information. Thank you for identifying the problem.