...

View Full Version : Cannot use appendChild('img') in IE



ChristopherVA
01-27-2006, 08:25 PM
I cannot get an appendChild(img) in the following code snippet to work in IE. However, the same script works without any problems in Firefox and Netscape 7.0 The error that is produced in IE is invalid argument. I have used a try/catch block in expectation of producing a better error message however the error message that is received is [objectError]. Will someone please help. PLEASE!!!!

var pageDiv = window.parent.fraTop.document.getElementById('pageTitle');
if(pageDiv!=null)
{
while(pageDiv.hasChildNodes())
{
pageDiv.removeChild(pageDiv.firstChild);
}

var img = document.createElement('img');
img.src='/wp2f/images/please_wait.gif';
pageDiv.appendChild(img);
}

KC-Luck
01-27-2006, 10:02 PM
var remoteDoc = window.parent.fraTop.document;
var pageDiv = remoteDoc.getElementById("pageTitle");
if (pageDiv != null) {
while (pageDiv.hasChildNodes()) pageDiv.removeChild(pageDiv.firstChild);
var newImage = remoteDoc.createElement("img");
newImage.src = "/wp2f/images/please_wait.gif";
pageDiv.appendChild(newImage);
}
The issue would be createElement within your present document, and trying to append it directly to the other window's document scope.

ChristopherVA
02-03-2006, 10:44 PM
Your fix worked. Thank you very much!!!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum