473,402 Members | 2,046 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,402 software developers and data experts.

trouble with .getElementId() in Firefox

I have a cgi program which outputs a fairly hefty amount of
html/javascript for doing a complex slide show sorta thing in a variety
of areas in the browser. I accomplish this by creating a series of
iframes and populating each iframe which its own copy of the code and a
list of items to display. It previously had it working tickety-boo
with both IE 6 and Firefox. I've had to concentrate on adding new
features to the IE side and am now attempting to get everything working
properly in Firefox.

The issue I'm running into is when I use the form
document.getElementById('some_id').someFunction Firefox often replies
that the object has no properties. I've handcoded some smaller
versions of the my program in straight html and, sure enough, they work
great. So, I'm screwing something up in my main program whereby
Firefox can't see the objects.

Has anyone else had this sort of problem and if so what did it turn out
to be? I'm looking for clues to know where to search...

The basic output of my program is (and my working test program is
similar)
<html>
<head>
<script type='text/javascript' language='javascript1.2'>

function myFunction(){
document.myObj.myFunction();
}

function runIt(){
setTimeout('myFunction()', 1000);
}
</script>
</head>
<body onLoad='runIt()'>
<object id='myObj' style='position:absolute; top:0; left:0;'
width='100' height='100'
CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'
type='application/x-oleobject'>
</object>
</body>
</html>

Any ideas where to look would be appreciated!

Dec 12 '06 #1
9 3787
ASM
johnd126 a écrit :
>
The issue I'm running into is when I use the form
document.getElementById('some_id').someFunction Firefox often replies
that the object has no properties.
Are you sure document.getElementById('some_id') exists ?

if(document.getElementById && document.getElementById('some_id'))
document.getElementById('some_id').someFunction();
else
alert('no layer with id "some_id" !');

I've handcoded some smaller
versions of the my program in straight html and, sure enough, they work
great. So, I'm screwing something up in my main program whereby
Firefox can't see the objects.

Has anyone else had this sort of problem and if so what did it turn out
to be? I'm looking for clues to know where to search...

The basic output of my program is (and my working test program is
similar)
<html>
<head>
<script type='text/javascript' language='javascript1.2'>

Is document.myObj (layer gotten by its Id) javascript 1.2 ?

could you try giving a *name* to your object (that has no data) ?

function myFunction(){
document.myObj.myFunction();
}

function runIt(){
setTimeout('myFunction()', 1000);
}
</script>
</head>
<body onLoad='runIt()'>
<object id='myObj' style='position:absolute; top:0; left:0;'
width='100' height='100'
CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'
type='application/x-oleobject'>
</object>
</body>
</html>

Any ideas where to look would be appreciated!

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 13 '06 #2

johnd126 wrote:
I have a cgi program which outputs a fairly hefty amount of
html/javascript for doing a complex slide show sorta thing in a variety
of areas in the browser. I accomplish this by creating a series of
iframes and populating each iframe which its own copy of the code and a
list of items to display. It previously had it working tickety-boo
with both IE 6 and Firefox. I've had to concentrate on adding new
features to the IE side and am now attempting to get everything working
properly in Firefox.

The issue I'm running into is when I use the form
document.getElementById('some_id').someFunction Firefox often replies
that the object has no properties. I've handcoded some smaller
versions of the my program in straight html and, sure enough, they work
great. So, I'm screwing something up in my main program whereby
Firefox can't see the objects.

Has anyone else had this sort of problem and if so what did it turn out
to be? I'm looking for clues to know where to search...

The basic output of my program is (and my working test program is
similar)
<html>
<head>
<script type='text/javascript' language='javascript1.2'>

function myFunction(){
document.myObj.myFunction();
}

function runIt(){
setTimeout('myFunction()', 1000);
}
</script>
</head>
<body onLoad='runIt()'>
<object id='myObj' style='position:absolute; top:0; left:0;'
width='100' height='100'
CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'
type='application/x-oleobject'>
</object>
</body>
</html>

Any ideas where to look would be appreciated!
For your object, you give the id='myObj' , which is the way you do it
for an ordinary object. However you also give the CLASSID which is a 32
digit hex id for an ActiveX object for the Windows Media Player. Having
2 ids for the object is likely to confuse some browers. In general IE
and close relatives support an ActiveX object, but usually Mozilla
family(Firefox, Netscape, Mozilla, Seamonkey) do not. Thus it would be
no surprise if the object, as written, does not work on Mozilla family
browsers. In general, scripting the WMP to work on different browsers
can be quite tricky.

Dec 13 '06 #3
For your object, you give the id='myObj' , which is the way you do it
for an ordinary object. However you also give the CLASSID which is a 32
digit hex id for an ActiveX object for the Windows Media Player. Having
2 ids for the object is likely to confuse some browers. In general IE
and close relatives support an ActiveX object, but usually Mozilla
family(Firefox, Netscape, Mozilla, Seamonkey) do not. Thus it would be
no surprise if the object, as written, does not work on Mozilla family
browsers. In general, scripting the WMP to work on different browsers
can be quite tricky.
One of the objects I'm having trouble with is indeed the windows media
player. It had been working previously (an earlier version of my
program, an earlier version of firefox, the same version of the
firefox activex extension) but now it won't talk to the object
correctly. I don't get an error when sending document.player.URL =
'file.wmv'; (although it won't work) but I'll get a 'object doesn't
support blah blah blah' when sending document.player.controls.play();
for example.

I should note that it makes no difference whether I use the
document.player. form or the document.getElementById('player'). form.
(I realized later that I'd muffed up my code example.) I mentioned the
..getElementById() form initially because there are other objects (a
form in one case) where I experience the same issue with it not being
able to access the object so I figured that the problem was something
more general. A small handcoded sample using code cut and pasted from
my larger program works fine. I've messed up something more
fundamental. I just see how!

Dec 13 '06 #4
Are you sure document.getElementById('some_id') exists ?
Yes, remember that a smaller, handcoded version of the program
containing (supposedly) the same code works brilliantly.

Dec 13 '06 #5
ASM
johnd126 a écrit :
>Are you sure document.getElementById('some_id') exists ?

Yes, remember
I do , I do, it's why.

(hand.coded != script.coded) :-)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 13 '06 #6

johnd126 wrote:
For your object, you give the id='myObj' , which is the way you do it
for an ordinary object. However you also give the CLASSID which is a 32
digit hex id for an ActiveX object for the Windows Media Player. Having
2 ids for the object is likely to confuse some browers. In general IE
and close relatives support an ActiveX object, but usually Mozilla
family(Firefox, Netscape, Mozilla, Seamonkey) do not. Thus it would be
no surprise if the object, as written, does not work on Mozilla family
browsers. In general, scripting the WMP to work on different browsers
can be quite tricky.

One of the objects I'm having trouble with is indeed the windows media
player. It had been working previously (an earlier version of my
program, an earlier version of firefox, the same version of the
firefox activex extension) but now it won't talk to the object
correctly. I don't get an error when sending document.player.URL =
'file.wmv'; (although it won't work) but I'll get a 'object doesn't
support blah blah blah' when sending document.player.controls.play();
for example.

I should note that it makes no difference whether I use the
document.player. form or the document.getElementById('player'). form.
(I realized later that I'd muffed up my code example.) I mentioned the
.getElementById() form initially because there are other objects (a
form in one case) where I experience the same issue with it not being
able to access the object so I figured that the problem was something
more general. A small handcoded sample using code cut and pasted from
my larger program works fine. I've messed up something more
fundamental. I just see how!
You do not need to use ActiveX to play windows media. Although WMP
ActiveX plugins for some of the Mozilla family browsers are available,
you can not count on most people having them installed, and indeed
there is no need to do so. Morever, most of these plugins do not
support ActiveX controls on Real, Flash, Mov, and several other
formats. The specialized scripting described on the Microsoft developer
sites often does not work on browsers other than IE or players other
than the WMP.

You can support several formats on the same page and control selection
of them with normal javascript. See
http://www.cwdjr.info/temp/video_multiFormat2.php . Be sure to read the
comments in the source, because scripting these players requires a few
tricks. What might seem would work often will not, and you have to find
another route. My example is designed mostly for broadband and uses
video, but the principle is the same for audio files. The page may work
for dialup, but buffering time would become excessive for many of the
examples. My examples work on recent versions IE6, Opera, and the
Mozilla family(Firefox, Netscape, Mozilla, Seamonkey).
>From long experience, I suggest avoiding ActiveX when at all possible
and avoiding the Microsoft developer site instructions on scripting, if
you want to write code to support most modern players.

Dec 13 '06 #7
VK
johnd126 wrote:
The basic output of my program is (and my working test program is
similar)
<html>
<head>
<script type='text/javascript' language='javascript1.2'>

function myFunction(){
document.myObj.myFunction();
}

function runIt(){
setTimeout('myFunction()', 1000);
}
</script>
</head>
<body onLoad='runIt()'>
<object id='myObj' style='position:absolute; top:0; left:0;'
width='100' height='100'
CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'
type='application/x-oleobject'>
</object>
</body>
</html>

Any ideas where to look would be appreciated!
This will not work for Firefox for 3 reasons, one main and two
additional:

[Reason One]

Media plugin support on Gecko browsers badly sucks.

Simply clicking a link like
<http://members.aol.com/jrzycrim01/mozilla/wmp/vidtest-LS.wmvwill
successfully launch WMP wherever installed, no problems whatsoever.

At the same time with WMP embedded into the page itself you cut off
50%-80% of Firefox users with WMP installed. It will work only for very
lucky ones where the installation and ActiveX registration passed by
extremely picky, tricky and fragile Firefox requirements.
That means that irrelevant to your current problems it is highly
suggested to check something like:
WMP.isPlayerInstalled = (
(typeof navigator.mimeTypes != 'undefined')
&& (typeof navigator
.mimeTypes['video/x-ms-wmv'] != 'undefined')
&& (typeof navigator.mimeTypes['video/x-ms-wmv']
.enabledPlugin != 'undefined')
&& (typeof navigator.mimeTypes['video/x-ms-wmv']
.enabledPlugin.name == 'string')
&& (navigator.mimeTypes['video/x-ms-wmv']
.enabledPlugin.name.indexOf('Windows Media Player') != -1));
and embed into page only if true. If false then still provide regular
links to wmv files if on Windows platform: the chances are very high
that WMP is perfectly here, just not "visible" to the browser.

[Reason Two]

Firefox doesn't allow to embed a *player* - you can only embed a
*really existing media file*. Embedding such file will lead to
embedding WMP itself, but the second cannot happen without the first.
URL check goes first, so with a bogus media file the embedding will not
happen. Moreover both [data] attribute and [src] param have to be set
and point to the same valid file. You are not getting headache yet? ;-)
Then I'll continue.
This way a working <objectcode for Firefox will be:
<object data="some_real.wmv"
type="video/x-ms-wmv"
width="320" height="320">
<param name="ShowStatusBar" value="1">
<param name="src" value="some_real.wmv">
<param name="autostart" value="0">
<param name="volume" value="0">
</object>

[Reason Three]
To embed media plugins into page it is possible to use both <object>
and <embed>. The "catch 22" is that *only* <embedwill create
scriptable object, so you can contact it using JavaScript.

So the reason it works on your "big" page but fails on the posted short
sample is very simple: on the "big" page you are using the traditional
<object><embed></embed></objectcombo where Firefox takes the <embed>
part and so semi-working. Then you decided to "optimize" your code so
removed <embed- and Firefox got nuked.

Dec 14 '06 #8
[Reason One]
Media plugin support on Gecko browsers badly sucks.
Oh, definitely.
At the same time with WMP embedded into the page itself you cut off
50%-80% of Firefox users with WMP installed. It will work only for very
lucky ones where the installation and ActiveX registration passed by
extremely picky, tricky and fragile Firefox requirements.
This is true but not really an issue because the application will only
be played on systems set up for the purpose of running my application.
So, I don't mind that it's a bit annoying to set up providing it stays
working once it's built.
[Reason Two]

Firefox doesn't allow to embed a *player* - you can only embed a
*really existing media file*. Embedding such file will lead to
embedding WMP itself, but the second cannot happen without the first.
URL check goes first, so with a bogus media file the embedding will not
happen. Moreover both [data] attribute and [src] param have to be set
and point to the same valid file. You are not getting headache yet? ;-)
Then I'll continue.
This way a working <objectcode for Firefox will be:
<object data="some_real.wmv"
type="video/x-ms-wmv"
width="320" height="320">
<param name="ShowStatusBar" value="1">
<param name="src" value="some_real.wmv">
<param name="autostart" value="0">
<param name="volume" value="0">
</object>
This is interesting. I'm going to test with this and see if it works
better for me.
[Reason Three]
To embed media plugins into page it is possible to use both <object>
and <embed>. The "catch 22" is that *only* <embedwill create
scriptable object, so you can contact it using JavaScript.

So the reason it works on your "big" page but fails on the posted short
sample is very simple: on the "big" page you are using the traditional
<object><embed></embed></objectcombo where Firefox takes the <embed>
part and so semi-working. Then you decided to "optimize" your code so
removed <embed- and Firefox got nuked.
Actually, no. I used only the <object(no <embed>) in the larger
application and the smaller test. And it worked on the smaller test
and not in the larger application.

Thanks for your advice.

John

Dec 20 '06 #9
You do not need to use ActiveX to play windows media. Although WMP
ActiveX plugins for some of the Mozilla family browsers are available,
you can not count on most people having them installed, and indeed
there is no need to do so. Morever, most of these plugins do not
support ActiveX controls on Real, Flash, Mov, and several other
formats. The specialized scripting described on the Microsoft developer
sites often does not work on browsers other than IE or players other
than the WMP.
The systems which will use my application will be specially built to do
so so it's not problematic that the activex stuff only works on a small
subset ... we can specify which software to install. However, it has
to work! ;) I'm working on a method which doesn't require controling
the object. It's much clunkier but it will get the job done...
You can support several formats on the same page and control selection
of them with normal javascript. See
http://www.cwdjr.info/temp/video_multiFormat2.php . Be sure to read the
comments in the source, because scripting these players requires a few
tricks. What might seem would work often will not, and you have to find
another route. My example is designed mostly for broadband and uses
video, but the principle is the same for audio files. The page may work
for dialup, but buffering time would become excessive for many of the
examples. My examples work on recent versions IE6, Opera, and the
Mozilla family(Firefox, Netscape, Mozilla, Seamonkey).
The only scripting I see for wmp on your example page is code to hide
and show the entire control. This has always worked for me. I've been
having trouble with the loading and playing and stopping of the
control.
From long experience, I suggest avoiding ActiveX when at all possible
and avoiding the Microsoft developer site instructions on scripting, if
you want to write code to support most modern players.
It's like wrestling a gorilla!

Thanks for your help.

John

Dec 20 '06 #10

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

Similar topics

12
by: Harlan Messinger | last post by:
On the page at http://gavelcade.com/tests/trivia.html I'm expecting the headings and the text that follows them to be positioned without regard to image or the DIV that contains it, which is...
5
by: lkrubner | last post by:
Go to this page: http://www.publicpen.com/designer/mcControlPanel.php?arrangement=createweblogsForm.php You'll need to login, use these: username: designer password: designer123 This is...
0
by: R. Tschirley | last post by:
Hi all, I've got some annoying trouble with IE's display of my new website header. On my site, the corporate logo shall be right-aligned: ...
18
by: Steven | last post by:
Hi I'm new to js so this prob is a simple question but I haven't been able to solve it. I have 2 text fields which let me pick a graphic file and want to display then in 2 image place holders so...
12
by: swismiself | last post by:
Hi group, I'm having trouble with a website I'm working on for my boss. Normally I code my own html, but I was having trouble getting the right "look" for this site, so I decided to use a free...
9
by: =?Utf-8?B?Sm9obiBCYWlsZXk=?= | last post by:
I have a ASP .Net page that allows moving around items on the page through javascript. This page works fine in IE. In FireFox however, I have found that if the page is using XHTML 1.0...
6
randomfool
by: randomfool | last post by:
I'm having trouble setting an onmousedown function in firefox. It works fine in IE 7 but when I attempt to call the function in firefox I am getting an "event is not defined" error. ...
5
by: Shane807 | last post by:
in Javascript i can update <div> innerHTML with simple code <script type="text/javascript" language="javascript> function UpdateDivTag(){ document.getElementId("divtagid").innerHTML = "oh no...
12
by: rhino | last post by:
I'm having some problems with Sliding Doors, as described in an article in A List Apart (http://www.alistapart.com/articles/slidingdoors/) and as detailed in the CSS Tab Designer v2.0 program. ...
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
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,...
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
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,...
0
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...
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.