# \[JS\] createElement "Embed" Troubles

**URL:** <https://forum.kirupa.com/t/js-createelement-embed-troubles/187574>\
**Category:** web dev\
**Created:** [April 30, 2006, 5:21pm UTC](https://forum.kirupa.com/t/js-createelement-embed-troubles/187574 "2006-04-30T17:21:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigmtnskier](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@bigmtnskier](https://forum.kirupa.com/u/bigmtnskier)\
**Post date:** [April 30, 2006, 5:21pm UTC](https://forum.kirupa.com/t/js-createelement-embed-troubles/187574/1 "2006-04-30T17:21:17Z")

</div>

Hi there,

Do any of you know what is wrong with the following code? It works just fine in Firefox but \*wonderful \*IE throws the error “Invalid Argument.” I have narrowed it down to the very last line in the code segment below. Does IE not like adding \<embed\> tags programmatically using document.createElement? Are there any alternatives I could use?

What I am pretty much trying to do is add a an \<embed\> inside an \<object\> inside a \<div\>. As said earlier, It works fine in FF but IE has troubles with it.

```auto

var objLightboxImage = document.createElement("object");
objLightboxImage.setAttribute('id','lightboxImage');
objLightboxImage.setAttribute('classid','clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
objLightboxImage.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0');
objLightboxImage.setAttribute('width','550');
objLightboxImage.setAttribute('height','400');

var Param1 = document.createElement("param");
Param1.setAttribute('name','movie');
Param1.setAttribute('value','never');

var Param2 = document.createElement("param");
Param2.setAttribute('name','quality');
Param2.setAttribute('value','high');

var Embed = document.createElement("embed");

Embed.setAttribute("quality", "high");
Embed.setAttribute("width", "550");
Embed.setAttribute("height", "400");
Embed.setAttribute("align", "center");
Embed.setAttribute("type", "application/x-shockwave-flash");
Embed.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
Embed.setAttribute('id','lightboxImageEmbed');

objLightboxImage.appendChild(Param1);
objLightboxImage.appendChild(Param2);

//IE DOESN'T LIKE THIS LINE BELOW...
//If i add "return false" here there aren't any errors
objLightboxImage.appendChild(Embed);
//If i add it here however, IE says "Invalid Argument"

```

Thanks in advance :hugegrin:

-bigmtnskier

(ps. If you need more of the code, just ask and I’ll post it)
