trouble with .getElementId() in Firefox

J

johnd126

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!
 
A

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) ?
 
C

cwdjrxyz

johnd126 said:
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.
 
J

johnd126

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!
 
J

johnd126

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.
 
C

cwdjrxyz

johnd126 said:
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.
 
V

VK

johnd126 said:
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.wmv> will
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 <object> code 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* <embed> will 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></object> combo where Firefox takes the <embed>
part and so semi-working. Then you decided to "optimize" your code so
removed <embed> - and Firefox got nuked.
 
J

johnd126

[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 <object> code 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* <embed> will 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></object> combo 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
 
J

johnd126

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.
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
 

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

No members online now.

Forum statistics

Threads
473,821
Messages
2,569,748
Members
45,726
Latest member
RaleighAll

Latest Threads

Top