Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > trouble with .getElementId() in Firefox

Reply
Thread Tools

trouble with .getElementId() in Firefox

 
 
johnd126
Guest
Posts: n/a
 
      12-12-2006
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!

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      12-13-2006
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
 
Reply With Quote
 
 
 
 
cwdjrxyz
Guest
Posts: n/a
 
      12-13-2006

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.

 
Reply With Quote
 
johnd126
Guest
Posts: n/a
 
      12-13-2006
> 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!

 
Reply With Quote
 
johnd126
Guest
Posts: n/a
 
      12-13-2006

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

 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      12-13-2006
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
 
Reply With Quote
 
cwdjrxyz
Guest
Posts: n/a
 
      12-13-2006

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.

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      12-13-2006
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.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.

 
Reply With Quote
 
johnd126
Guest
Posts: n/a
 
      12-20-2006
> [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

 
Reply With Quote
 
johnd126
Guest
Posts: n/a
 
      12-20-2006
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox and URL (DNS?) resolution trouble scorpius Firefox 3 11-22-2006 10:21 AM
Firefox -- trouble clicking on tabs Keith Lee Firefox 0 10-28-2006 01:22 PM
i have no trouble to send , ihave trouble reciving mail --any ideas John Penney Computer Support 4 08-29-2006 08:45 PM
Trouble rendering form panels in firefox and netscape V Arzola ASP .Net 0 03-21-2006 03:57 PM
trouble with caching or caching the trouble Hypo ASP .Net 6 08-01-2003 07:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57