Connecting Tech Pros Worldwide Forums | Help | Site Map

onClick interaction with applet in Mozilla

For Example: John Smith
Guest
 
Posts: n/a
#1: Jul 20 '05
Hello!

Javascript beginner here, looking for some help. I discovered this
problem tonight while playing with my site using Mozilla. I don't have
Netscape on this computer but I assume this problem would exisist there
as well.

I am interacting with a Java applet (open source, which I did not write)
using javascript. The author of the applet has provided basic
information regarding how javascript can be used to manipulate the applet.

For instance, this function is defined in my javascript file:

function setTool(tool){
var map=top.appletframe.document.applets['mapApplet'].getMap();
map.setTool(tool);
}

and then an onClick is used to set the tool:

<a href="#"><img "zoom.gif" alt="Zoom In" name="selecttool"
onClick="setTool(2)"></a>

The frame holding the applet is named "appletframe".

This works perfectly well in Internet Explorer. However, in Mozilla
(1.4), it does nothing. I get no errors, no nothing.

Can someone offer a suggestion as to how this could be made to work with
browsers other than IE? I have been (and continue to) search the
javascript manuals & google, but would appreciate your help if you can
offer any. It's rather frustrating researching a problem when the
browser doesn't even return an error.

Thank you!

Newsgroup replies only, please.



For Example: John Smith
Guest
 
Posts: n/a
#2: Jul 20 '05

re: onClick interaction with applet in Mozilla



Berend de Boer wrote:[color=blue][color=green][color=darkred]
>>>>>>"For" == For Example: John Smith <none@host.invalid> writes:[/color][/color]
>
>
> For> This works perfectly well in Internet Explorer. However, in
> For> Mozilla (1.4), it does nothing. I get no errors, no nothing.
>
> You mean no errors in the Javascript console of Mozilla?
>
>[/color]

Well, actually...

It seems there's nothing wrong with it, after all.

For some reason, in Mozilla, I have to click and sort of hold the link
for a fraction of a second - then it works. In IE I just click & move &
it works.

Sorry for the bother, guess it's just the way Mozilla handles the
onClick event.

Thanks!


Laurent Bugnion, GalaSoft
Guest
 
Posts: n/a
#3: Jul 20 '05

re: onClick interaction with applet in Mozilla


Hi,

For Example: John Smith wrote:
[color=blue]
> Hello!
>
> Javascript beginner here, looking for some help. I discovered this
> problem tonight while playing with my site using Mozilla. I don't have
> Netscape on this computer but I assume this problem would exisist there
> as well.
>
> I am interacting with a Java applet (open source, which I did not write)
> using javascript. The author of the applet has provided basic
> information regarding how javascript can be used to manipulate the applet.
>
> For instance, this function is defined in my javascript file:
>
> function setTool(tool){
> var map=top.appletframe.document.applets['mapApplet'].getMap();
> map.setTool(tool);
> }
>
> and then an onClick is used to set the tool:
>
> <a href="#"><img "zoom.gif" alt="Zoom In" name="selecttool"
> onClick="setTool(2)"></a>
>
> The frame holding the applet is named "appletframe".
>
> This works perfectly well in Internet Explorer. However, in Mozilla
> (1.4), it does nothing. I get no errors, no nothing.
>
> Can someone offer a suggestion as to how this could be made to work with
> browsers other than IE? I have been (and continue to) search the
> javascript manuals & google, but would appreciate your help if you can
> offer any. It's rather frustrating researching a problem when the
> browser doesn't even return an error.
>
> Thank you!
>
> Newsgroup replies only, please.[/color]

IMG tags have no ONCLICK event handler. IE interpretes what you want to
do and does something, whereby Mozilla reacts correctly and does
nothing. IE often does this kind of things, which is why it's always
better to develop in Mozilla and to check if it works in IE afterwards.

To solve your problem, try this:

<a href="#" onClick="setTool(2);return false;">
<img "zoom.gif" alt="Zoom In" name="selecttool"></a>

Note however that if the applet is an OBJECT tag, you cannot script it
in Mozilla, this is a documented error. Only APPLET tags can be scripted.

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Closed Thread