Click to See Complete Forum and Search --> : document.createElement("object") problem


craftymind
09-18-2003, 11:44 PM
I can successfully create a new flash object but can't get params inserted into it.
A flash object in IE should look like this.

<object id="flashmovie" width="300" height="100" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="movie" value="flashmovie.swf">
</object>



This is my function for adding flash to the html body, but I don't know how to get <param name="movie" value="flashmovie.swf"> into the object.
The commented code is everything I've tried so far but doesn't work.

function addFlash(){
var flash = document.createElement("object");
flash.id = "flashmovie";
flash.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
flash.width = "300";
flash.height = "100";
//flash.innerHTML = "<param name='movie' value='hexit.swf'>";
//flash.createElement("<param name='movie' value='hexit.swf'>");
document.body.appendChild(flash);
}


How can I get that param attached?
Thanks

Gollum
09-19-2003, 02:48 AM
Have you tried...

var oSpan = document.createElement("span");
document.body.appendChild(oSpan);
oSpan.innerHTML = '<object id="flashmovie" width="300" height="100" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="flashmovie.swf"></object>';

I've not much experience using flash, but I'm guessing it might work

Khalid Ali
09-19-2003, 08:08 AM
Just so you know, An even better approach will be to use

newElement.setAttribute("attributeName","value");

craftymind
09-19-2003, 12:51 PM
thanks guys