473,800 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.create Element('flashe r')
var obj = createflashObje ct(name, width, height);
box.appendChild (obj);
obj.appendChild (createParam('m ovie', name));
obj.appendChild (createParam('q uality', 'high'));
obj.appendChild (createParam('b gcolor', '#000000'));
return box;
}

function createflashObje ct(name, width, height) {
var obj = document.create Element('object ');
obj.setAttribut e('type', 'application/x-shockwave-flash');
obj.setAttribut e('data', name);
obj.setAttribut e('width', width);
obj.setAttribut e('height', height);
return obj;
}

function createParam(n, v) {
var el = document.create Element('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="makefla sh('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 4480
VK

windandwaves wrote:
var box = document.create Element('flashe r')


AFAIK there is not such HTML element. You maybe wanted to say:

var box = document.create Element('OBJECT ');
box.id = 'flasher';

?

Feb 16 '06 #2
VK wrote:
windandwaves wrote:
var box = document.create Element('flashe r')
AFAIK there is not such HTML element. You maybe wanted to say:

var box = document.create Element('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.getEl ementById) {
this.obj = document.getEle mentById(name);
this.style = document.getEle mentById(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:
windandwave s wrote:
var box = document.create Element('flashe r')
AFAIK there is not such HTML element. You maybe wanted to say:

var box = document.create Element('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.getEl ementById) {
this.obj = document.getEle mentById(name);
this.style = document.getEle mentById(name). style;
}
}


That could be better written as:

function getObj(name)
{
this.obj = null;
this.style = null;

if (document.getEl ementById) {
this.obj = document.getEle mentById(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.appendC hild(obj);
or:

box.obj && box.obj.appendC hild && box.obj.appendC hild(obj);

--
Rob
Feb 17 '06 #4
RobG wrote:
windandwaves wrote:
VK wrote:
windandwaves wrote:

var box = document.create Element('flashe r')

AFAIK there is not such HTML element. You maybe wanted to say:

var box = document.create Element('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.getEl ementById) {
this.obj = document.getEle mentById(name);
this.style = document.getEle mentById(name). style;
}
}


That could be better written as:

function getObj(name)
{
this.obj = null;
this.style = null;

if (document.getEl ementById) {
this.obj = document.getEle mentById(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.appendC hild(obj);
or:

box.obj && box.obj.appendC hild && box.obj.appendC hild(obj);


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

function getObj(name) {
this.obj = null;
this.style = null;
if (document.getEl ementById) {
this.obj = document.getEle mentById(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.layer s) {
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.getEle mentById("flash er");
var obj = createflashObje ct(name, width, height);
box.appendChild (obj);
obj.appendChild (createParam('m ovie', name));
obj.appendChild (createParam('q uality', 'high'));
obj.appendChild (createParam('b gcolor', '#000000'));
return box;
}

function createflashObje ct(name, width, height) {
var obj = document.create Element('object ');
obj.setAttribut e('type', 'application/x-shockwave-flash');
obj.setAttribut e('data', name);
obj.setAttribut e('width', width);
obj.setAttribut e('height', height);
return obj;
}

function createParam(n, v) {
var el = document.create Element('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="applicati on/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.create Element('flashe r')

AFAIK there is not such HTML element. You maybe wanted to say:

var box = document.create Element('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.getEl ementById) {
this.obj = document.getEle mentById(name);
this.style = document.getEle mentById(name). style;
}
}


That could be better written as:

function getObj(name)
{
this.obj = null;
this.style = null;

if (document.getEl ementById) {
this.obj = document.getEle mentById(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.appendC hild(obj);
or:

box.obj && box.obj.appendC hild && box.obj.appendC hild(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.getEle mentById("flash er");


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.getEle mentById("flash er");


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
762
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 scripting and CSS2 background imagery. I am hoping that someone out there can help me identify what steps I might take to remedy this situation. Perhaps it is something that Macromedia might be able to do something about, since getting IE fixed is...
9
8608
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 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). On the aspx page I have the object tag as follows:
31
3097
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 together a website that uses his domain name and url directs to my server. It has a (sorry) flash intro page that continues to his main page. When I click on a navigation button, the address reverts back to my webpage address. Without using shitty frames...
1
3802
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 on our server, there is a breakdown when it tries to load .FLV files sequentially. All the files share the same directory. There are no 'subfolders', all files are in the same root folder called group_quote. Given that the sequential loading...
1
1968
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 link to those files through the web page. but this is sometime run slow and takes long time to load the swift/flash files. Is there a better way/solution to add to web pages. Thank you in advance for your help.
0
1611
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 suggested they had an img tag with src="", I decided to look for instances of "src" and one by one start removing that code to see if it changed anything. Below is the one that, when I removed it, although it broke the flash menus and header, solved...
5
5951
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 say "Hello World" in a Flash enabled web page rendered via ASP.NET. Can any one let me get started? ---
2
3744
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 icons(images) instead of text. (yes i'm being difficult) and i'd like the text to load into a static placeholder symbol instead. Problem is, I can get images to load in a separate file, text to load in a separate file, and text to appear in a static...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.