Error when using the appendChild method with IE6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hastiok
    New Member
    • Dec 2009
    • 7

    Error when using the appendChild method with IE6

    Hello EveryOne,

    I have a problem with ie6 when using the appendChild method.
    I have tested my code on ie8, FireFox and chrome and I don't have any problem.
    I give you the code:

    Code:
    pic = new Image();
    pic.id = "img_thumb_"+id;
    //pic.name = "img_thumb_"+id;
    pic.src = "get_mini_image.php?archId="+id;
    pic.style.display = "block";
    pic.style.position = "absolute";
    pic.style.top = "10%";
    pic.style.left = "64%";
    parent.document.getElementById("id_DIV").appendChild(pic);
    Thank you in advance for your help
    Last edited by Dormilich; Dec 9 '09, 10:52 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I suspect the call window.parent.d ocument not to work. btw. what is the error message?

    Comment

    • hastiok
      New Member
      • Dec 2009
      • 7

      #3
      I'm sure that the cause of my error is the appendChild method. [ I tried not to use it, I don't have an error message]
      The messag of error is : Invalid Argument.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        seems like IE6 requires an Element/HTMLElement as input (i.e. created with the document.create Element() method)

        Comment

        • hastiok
          New Member
          • Dec 2009
          • 7

          #5
          I have tried this alternative:
          var pic = document.ceateE lement("IMG");
          I still have the same error.
          I don't understand what wrong when using appendChild with ie6 !!!!
          I don't have any error with ie8 !!!!

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            well, this is beyond my abilities, since I don’t have IE to test myself. ;_;

            Comment

            • hastiok
              New Member
              • Dec 2009
              • 7

              #7
              thank you for your intrest.
              If you would like to test, you can download IETester, it is a free application allowing developpers to test their code with all IE version.
              You can find it in : http://ietester.softonic.fr/telecharger

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                unfortunately this requires a Windows operating system… and I’m running on freeBSD.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  The problem is you're creating the element in this document and then appending to the parent document. Use parent.createEl ement(...) to create the element and append.

                  Comment

                  • hastiok
                    New Member
                    • Dec 2009
                    • 7

                    #10
                    thank you so much acoder, it's the solution for my problem

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      Cool. Glad you got it working.

                      Comment

                      Working...