473,394 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

adding flash on load

Hi Folk

I am trying to add flash onload

This is the function I came up with:

function makeflash(name, width, height) {
//if (!DHTML) return;
name = 'v/' + name + '.swf';
var box = document.createElement('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;
}

It does not give any errors, but it is not working either.

my html looks as follows:

....header here
<body onload="makeflash('abc.swf', 100, 100);">
<div id="flasher"></div>
....etc...

I should probably use getelementbyid rather than createlement, but that does
not seem to work either

any help greatly appreciated.

Thank you
Nicolaas

Feb 16 '06 #1
7 4460
VK

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

?

Feb 16 '06 #2
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;
}
}

Now the error is box.appendChild is not a function.

I am not sure how to proceed.

Can you help
Nicolaas

Feb 17 '06 #3
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);

--
Rob
Feb 17 '06 #4
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
Feb 17 '06 #5
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);


Email me (javascript at ngaru.com) to see an example...

Thank you.

- Nicolaas
Feb 17 '06 #6
windandwaves wrote:
[...]

I changed my function to this now and IT IS WORKING!

function getObj(name) { [...] }
This function is not called, so it isn't used.
/**
* Create a flash object
*/

function makeflash(name, width, height) {
//if (!DHTML) return;
name = 'v/' + name + '.swf';
var box = document.getElementById("flasher");


Despite the feature testing you added to getObj(), you bypass it
completely here by using a direct call to getElementById.

But that is irrelevant to why it won't work in IE (i.e. IE 5+).
[...]


--
Rob
Feb 17 '06 #7
RobG wrote:
windandwaves wrote:
[...]

I changed my function to this now and IT IS WORKING!

function getObj(name) {

[...]
}


This function is not called, so it isn't used.
/**
* Create a flash object
*/

function makeflash(name, width, height) {
//if (!DHTML) return;
name = 'v/' + name + '.swf';
var box = document.getElementById("flasher");


Despite the feature testing you added to getObj(), you bypass it
completely here by using a direct call to getElementById.

But that is irrelevant to why it won't work in IE (i.e. IE 5+).
[...]


Hi Rob

Yes, sorry, that was the main focus of my project. I am still a JS
beginner, but this time I am trying to get a flash file to load "onload".
the reason I am doing this is because I want to display the rest of the page
ASAP and the flash file is rather large.

Thanks for your help

- Nicolaas
Feb 17 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Drew D. Saur | last post by:
When working on a web site for my employer, I uncovered what appears to be an undocumented bug in Internet Explorer 5 & 6 for Windows in regard to a (perhaps uncommon?) integration of Flash...
9
by: Keith Rowe | last post by:
Hello, I am trying to reference a Shockwave Flash Object on a vb code behind page in an ASP.NET project and I receive the following error: Guid should contain 32 digits with 4 dashes...
31
by: wallster | last post by:
please keep the flaming to a minimum (a bucket of water is next to me) but I have a question someone here might be able to explain in basic terms for a dunce like me. I helped a friend put...
1
by: redet | last post by:
A demo created by a person who has since left, runs fine on a local (Windows XP) system within flash player 8, but when we try to access it through the html version (index.html) on a local system or...
1
by: =?Utf-8?B?SGFr?= | last post by:
HI All, please, please help me the best solution to add Swift/Falsh files to .NET 2 web page. i thought the best way is to add a folder with all your Swift/Flash files to my project and creat a...
0
by: manywolf | last post by:
I have an aspx page that fires the page load event twice for every load. I tried every fix that was suggested in all the posts on this and other forums. None changed the behavior. After one post that...
5
by: ASP.NET explorer | last post by:
I have been asked to create some simple animation using Adobe Flash player in ASP.NET(C#) web application. While I am fairly well versed with ASP.NET C#, I absolutely have NO IDEA about how to...
2
elamberdor
by: elamberdor | last post by:
Hi All! Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map, ..well now I want to load in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.