invalid argument with appendChild

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Poulos

    #1

    invalid argument with appendChild

    If I try to append a PARAM tag twice I'm having problems:


    var.medDiv = document.getEle mentById("myDiv ");

    var medObj = document.create Element("object ");

    var p = document.create Element("param" );
    p.setAttribute( "FileName",this .URL);
    medObj.appendCh ild(p);

    p = document.create Element("param" );
    p.setAttribute( "AutoStart","fa lse");
    medObj.appendCh ild(p); // <-- this one

    medDiv.appendCh ild(medObj);


    The line with the "this one" comment triggers IE to tell me that it has
    an invalid argument. If I change the order of the PARAMs then the new
    second PARAM will give me the error. If I move the setAttribute to after
    the appendChild I still get the error.

    I'm unsure what's wrong.

    Andrew Poulos
  • RobG

    #2
    Re: invalid argument with appendChild

    Andrew Poulos wrote:[color=blue]
    > If I try to append a PARAM tag twice I'm having problems:
    >
    >
    > var.medDiv = document.getEle mentById("myDiv ");[/color]

    var medDiv...

    Perhaps? Loose the '.' between 'var' and 'medDiv'

    [...]

    --
    Rob

    Comment

    • Andrew Poulos

      #3
      Re: invalid argument with appendChild

      RobG wrote:[color=blue]
      > Andrew Poulos wrote:
      >[color=green]
      >> If I try to append a PARAM tag twice I'm having problems:
      >>
      >>
      >> var.medDiv = document.getEle mentById("myDiv ");[/color]
      >
      >
      > var medDiv...
      >
      > Perhaps? Loose the '.' between 'var' and 'medDiv'[/color]

      Dang that was my typing the question out not the code I'm using. That is
      the code I'm using does have

      var medDiv...

      I'm still stuck the second call to appnedChild of a PARAM element
      causes IE to choke and I can't fix it.

      Andrew Poulos

      Comment

      • Michael Winter

        #4
        Re: invalid argument with appendChild

        On Mon, 24 Jan 2005 23:02:06 +1100, Andrew Poulos <ap_prog@hotmai l.com>
        wrote:

        [snip]
        [color=blue]
        > var p = document.create Element("param" );
        > p.setAttribute( "FileName",this .URL);
        > medObj.appendCh ild(p);[/color]

        You aren't setting the attributes properly:

        p.name = 'FileName';
        p.value = this.URL;

        Likewise for the second PARAM element.

        [snip]

        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • Andrew Poulos

          #5
          Re: invalid argument with appendChild

          Michael Winter wrote:
          [color=blue]
          > On Mon, 24 Jan 2005 23:02:06 +1100, Andrew Poulos <ap_prog@hotmai l.com>
          > wrote:
          >
          > [snip]
          >[color=green]
          >> var p = document.create Element("param" );
          >> p.setAttribute( "FileName",this .URL);
          >> medObj.appendCh ild(p);[/color]
          >
          >
          > You aren't setting the attributes properly:
          >
          > p.name = 'FileName';
          > p.value = this.URL;
          >
          > Likewise for the second PARAM element.
          >
          > [snip]
          >[/color]
          When I do setAtribute/appendChild twice it gives me an error in IE 5,
          5.5, and 6. If I go the name value pairing/appendChild twice it 'works'
          in IE6 but not 5 or 5.5.

          I'm beginning to think that IE has trouble with OBJECT tags that are
          dynamically added using DOM methods.

          Andrew Poulos

          Comment

          • Fred Oz

            #6
            Re: invalid argument with appendChild

            Andrew Poulos wrote:[color=blue]
            > If I try to append a PARAM tag twice I'm having problems:[/color]
            [...]

            Given the above posts, I can only suggest using "var" when declaring
            'p' in both instances:

            var p = document.create Element("param" );
            p.name = FileName
            [...]

            var p = document.create Element("param" );
            [...]

            Alternatively, use a different variable name for the second PARAM
            and see if that works.

            --
            Rob

            Comment

            • Andrew Poulos

              #7
              Re: invalid argument with appendChild

              Fred Oz wrote:[color=blue]
              > Andrew Poulos wrote:
              >[color=green]
              >> If I try to append a PARAM tag twice I'm having problems:[/color]
              >
              > [...]
              >
              > Given the above posts, I can only suggest using "var" when declaring
              > 'p' in both instances:
              >
              > var p = document.create Element("param" );
              > p.name = FileName
              > [...]
              >
              > var p = document.create Element("param" );
              > [...]
              >
              > Alternatively, use a different variable name for the second PARAM
              > and see if that works.[/color]

              Thanks. I tried it, and about a million other things, and it made no
              difference. I'm seriously starting to believe that IE does not like
              people using DOM methods to dynamically create OBJECT tags.


              Andrew Poulos

              Comment

              • Andrew Poulos

                #8
                Re: invalid argument with appendChild

                >[color=blue]
                > Thanks. I tried it, and about a million other things, and it made no
                > difference. I'm seriously starting to believe that IE does not like
                > people using DOM methods to dynamically create OBJECT tags.[/color]

                Well I should've looked here in the first place:
                <url:
                http://msdn.microsoft.com/library/de...ppendchild.asp[color=blue]
                >[/color]

                It seems the OBJECT tag with appendChild is not supported in IE. Sorry
                for wasting people's time.

                Andrew Poulos

                Comment

                Working...