This small piece of code works in Firefox but not in IE 7... why?



Hello,
How hard could it be to create the embeded youtube object in
JavaScript DOM ? ....
I've create the code and it works ok in Firefox but in IE7 i get an
invalid argument error.

Can someone tell me what im doing wrong?


For reference, this is the embebed youtube video object:
<object width="425" height="350"><param name="movie" value="http://
www.youtube.com/v/dMH0bHeiRNg"></param><param name="wmode"
value="transparent"></param><embed src="http://www.youtube.com/v/
dMH0bHeiRNg" type="application/x-shockwave-flash" wmode="transparent"
width="425" height="350"></embed></object>


This is my attempt to create it using the JavaScript DOM:

function video()
{
var div = document.getElementById("content"); //insert the video in
this div

//create the youtube object
var object1 = document.createElement('object');
object1.setAttribute('width','425');
object1.setAttribute('height','350');

var param1 = ce('param','movie');
param1.setAttribute('value','http://www.youtube.com/v/dMH0bHeiRNg');
object1.appendChild(param1);

var param2 = ce('param','wmode');
param2.setAttribute('value','transparent');
object1.appendChild(param2);

var embed1 = document.createElement('embed');
embed1.setAttribute('width','425');
embed1.setAttribute('height','350');
embed1.setAttribute('wmode','transparent');
embed1.setAttribute('type','application/x-shockwave-flash');
embed1.setAttribute('src','http://www.youtube.com/v/dMH0bHeiRNg');

object1.appendChild(embed1);

div.appendChild(object1); //insert the video
}



function ce(tag,name)
{
if (name && window.ActiveXObject)
{
element = document.createElement('<'+tag+' name="'+name+'">');
}
else
{
element = document.createElement(tag);
element.setAttribute('name',name);
}

return element;
}


Why IE7 gives me an error but Firefox not?


Thanks
Marco

.



Relevant Pages