unexpected call error in IE 5

A

Andrew Poulos

I'm dynamically building some html OBJECT code and I use this function
to and PARAM elements:

// function to add a PARAM element to an element (parent, name, value)
addParam = function(prt,n,v) {
var p = document.createElement("param");
p.name = n;
p.value = v;
prt.appendChild(p);
}

It appears to work fine with IE6, MZ1.7.5, and FF1.0 but IE5 and 5.5
complain that the line "par.appendChild(p);" does this:

"unexpected call to method or property access"

What's happening and how can it be fixed?

Andrew Poulos
 
M

Martin Honnen

Andrew said:
I'm dynamically building some html OBJECT code and I use this function
to and PARAM elements:

// function to add a PARAM element to an element (parent, name, value)
addParam = function(prt,n,v) {
var p = document.createElement("param");
p.name = n;
p.value = v;
prt.appendChild(p);
}

It appears to work fine with IE6, MZ1.7.5, and FF1.0 but IE5 and 5.5
complain that the line "par.appendChild(p);" does this:

"unexpected call to method or property access"

What's happening and how can it be fixed?

IE (at least on Win) unfortunately is a bit picky about the elements you
can call methods like appendChild on, the documentation
<http://msdn.microsoft.com/library/d...uthor/dhtml/reference/methods/appendchild.asp>
indeed doesn't list <object> and I remember similar problems when trying
to call appendChild on a <style> or <script> element object.
Sometimes more IE specific properties or methods do work, for <object>
insertAdjacentElement is documented so perhaps
if (prt.insertAdjacentElement) {
prt.insertAdjacentElement('beforeEnd', p);
}
else if (prt.appendChild) {
prt.appendChild(p);
}
but I haven't tested that, try yourself, if it doesn't work you might
need to try other ways (calling insertAdjacentHTML where you want to
insert the complete <object> or setting innerHTML or outerHTML of an
element to insert the markup for <object> and its <param>s).
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top