RobG wrote:
windandwaves wrote: VK wrote:
windandwaves wrote:
var box = document.createElement('flasher')
AFAIK there is not such HTML element. You maybe wanted to say:
var box = document.createElement('OBJECT');
box.id = 'flasher';
?
You are so right. However, we create the object element further
down. I have added this instead:
var box = new getObj("flasher");
where getObj returns the object ()
function getObj(name) {
if (document.getElementById) {
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
}
That could be better written as:
function getObj(name)
{
this.obj = null;
this.style = null;
if (document.getElementById) {
this.obj = document.getElementById(name);
}
if (this.obj && this.obj.style){
this.style = this.obj.style;
}
}
Now the error is box.appendChild is not a function.
No, it's not. box is a instance of your - getObj - object, and you
haven't defined an appendChild method for it. I think what you really
want to do is call the appendChild method of the element referenced by
box.obj (if there is one), i.e.:
box.appendChild(obj);
should be:
box.obj.appendChild(obj);
or:
box.obj && box.obj.appendChild && box.obj.appendChild(obj);
I changed my function to this now and IT IS WORKING!
function getObj(name) {
this.obj = null;
this.style = null;
if (document.getElementById) {
this.obj = document.getElementById(name);
if (this.obj && this.obj.style){
this.style = this.obj.style;
}
}
else if (document.all) {
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers) {
this.obj = document.layers[name];
this.style = document.layers[name];
}
}
/**
* Create a flash object
*/
function makeflash(name, width, height) {
//if (!DHTML) return;
name = 'v/' + name + '.swf';
var box = document.getElementById("flasher");
var obj = createflashObject(name, width, height);
box.appendChild(obj);
obj.appendChild(createParam('movie', name));
obj.appendChild(createParam('quality', 'high'));
obj.appendChild(createParam('bgcolor', '#000000'));
return box;
}
function createflashObject(name, width, height) {
var obj = document.createElement('object');
obj.setAttribute('type', 'application/x-shockwave-flash');
obj.setAttribute('data', name);
obj.setAttribute('width', width);
obj.setAttribute('height', height);
return obj;
}
function createParam(n, v) {
var el = document.createElement('param');
el.setAttribute('name', n);
el.setAttribute('value', v);
return el;
}
However, not in IE. Does anyone know how to get this baby going in IE?
I am basically trying to get this, but only after the page has been loaded.
The reason for this is that I use some other functions onload and i want
those to be carried out first as the flash is almost 1 meg and takes a while
to load....
<object type="application/x-shockwave-flash" data="v/index.swf"
width="875" height="215">
<param name="movie" value="v/index.swf" />
<param name="bgcolor" value="#000" />
<a title="You must install the Flash Plugin for your Browser in order
to view this movie"
href="http://www.macromedia.com/shockwave/download/alternates/">get the
required <q>plug-in</q>: Macromedia Flash</a>
</object>
TIA
- Nicolaas