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

S

SM

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','
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','

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
 
S

shimmyshack

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="
"></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','
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','

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

would UFO be any good to you? - google it for a unobtrusive x-browser
flash embedding script.
 
P

pranav.kamkhalia

I am facing the same problem, if you get the solution can you please
email the same at (e-mail address removed). Appreciate your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top