Andrew Poulos wrote:
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/default.asp?url=/workshop/author/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).
--
Martin Honnen
http://JavaScript.FAQTs.com/