By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

unexpected call error in IE 5

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


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/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.