PDA

View Full Version : modifying an <object> element


gnznroses
06-19-2009, 01:36 AM
I'm trying to modify an <object> element dynamically, to add
<param name="wmode" value="transparent">

i'm working with the standard youtube embed:
<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/adsasdrwr=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/adsasdrwr&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>

i've confirmed (with a dom inspector) that the code below adds the param, but apparently you need to destroy and then re-create the Object, in order for it to take effect?
var objParam = document.createElement("param");
objParam.setAttribute('wmode', 'transparent');
objObject.insertBefore(objParam, objObject.firstChild);

(i know <object> is only used in IE, but i used FF's dom inspector.)

to keep this short, removing and then recreating the <object> tag doesn't work in IE. in fact, simply removing it doesn't. but it works in FF -- removing the <object> gets rid of the embedded youtube video (the <embed> tag is a child of the <object> tag).

var objectz = document.getElementsByTagName('object');
for (n = 0; n < objectz.length; n++){
var obj = objectz[n];
var pn = obj.parentNode;
pn.removeChild(obj);
}

this has no effect in IE, and no error is thrown...

i've been working at this for hours so any help is much appreciated.

gnznroses
06-21-2009, 06:56 PM
i'll bump this just once ;)