Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Cannot use appendChild('img') in IE

    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);
    }

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    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.

  • #3
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your fix worked. Thank you very much!!!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •