invalid argument with appendChild

A

Andrew Poulos

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


var.medDiv = document.getElementById("myDiv");

var medObj = document.createElement("object");

var p = document.createElement("param");
p.setAttribute("FileName",this.URL);
medObj.appendChild(p);

p = document.createElement("param");
p.setAttribute("AutoStart","false");
medObj.appendChild(p); // <-- this one

medDiv.appendChild(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
 
R

RobG

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


var.medDiv = document.getElementById("myDiv");

var medDiv...

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

[...]
 
A

Andrew Poulos

RobG said:
var medDiv...

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

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
 
M

Michael Winter

[snip]
var p = document.createElement("param");
p.setAttribute("FileName",this.URL);
medObj.appendChild(p);

You aren't setting the attributes properly:

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

Likewise for the second PARAM element.

[snip]

Mike
 
A

Andrew Poulos

Michael said:
[snip]
var p = document.createElement("param");
p.setAttribute("FileName",this.URL);
medObj.appendChild(p);


You aren't setting the attributes properly:

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

Likewise for the second PARAM element.

[snip]
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
 
F

Fred Oz

Andrew said:
If I try to append a PARAM tag twice I'm having problems:
[...]

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

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

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

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

Andrew Poulos

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

[...]

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

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

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

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

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
 
A

Andrew Poulos

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top