PDA

View Full Version : can not get applet handle by javascript in firefox



zhangleif
08-15-2005, 04:20 PM
I am running out of wisdom while calling applet by javascript in firefox 1.0.4. But the same code works in IE6. Any help here is greatly appreciated.

I always get the value of applet handle as null in firefox. The below is the line of code, I am calling it from another frame. And the API is the name of applet defined in jsp/html as showed at the bottom of this post.

var theApplet = parent.frames["mscp"].document.getElementById(API);

I found the value of theApplet I got is always null in firefox, but the same code is working in IE6. I have checked the parent.frames["mscp"].document has the valid value in firefox. And I also confirmed the applet in firefox working properly since it does generate correct logs while loading it. So, there is no issue with java environment with firefox.

I just do not know why the javascript code can not get hold of the applet in firefox, but it does in IE6.

And the below is the code where applet included in jsp, which is at frame "mscp".

<html>
....
<body>
.......
<APPLET
CODEBASE = "./lwtapplet"
NAME = "API"
ALT = "Tracking Applet"
CODE = "LWTApplet.class"
WIDTH = "300"
HEIGHT = "400"
HSPACE = "0"
VSPACE = "0"
ALIGN = "middle"
>

<param name="trackMode" value="<%=trackingMode%>" />
<param name="debugMode" value="<%=curParam%>" />
<param name="isVisible" value="<%=isVisible%>" />
<param name="userID" value="<%=request.getRemoteUser()%>" />
<param name="host" value="<%=request.getServerName()%>" />
<param name="bigDogValue" value="<%=bigDogValue%>" />
<param name="itrak.servlet.url" value="<%=servletURL%>" />
&nbsp;
</APPLET>
</body>
</html>

Does any one know what is wrong here? Thanks.

mwinter
08-16-2005, 01:04 AM
I always get the value of applet handle as null in firefox. The below is the line of code, I am calling it from another frame. And the API is the name of applet defined in jsp/html as showed at the bottom of this post.

&#160;&#160;var theApplet = parent.frames["mscp"].document.getElementById(API);Presumably you intended to quote API -> 'API'.

The reason is quite simple: you don't have an element with the id attribute value, 'API'. You have an applet element with a matching name attribute, but that isn't the same thing. Why it works with IE is also simple: IE is broken.

Use the applets collection instead:


var theApplet = parent.frames.mscp.document.applets.API;Hope that helps,
Mike

zhangleif
08-16-2005, 03:21 PM
You are right, got it.

Thanks a lot