Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Applets and the fly likes communication between applet and javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "communication between applet and javascript" Watch "communication between applet and javascript" New topic
Author

communication between applet and javascript

anil kumar N
Greenhorn

Joined: Mar 22, 2006
Posts: 8
I am using applet in a jsp through applet tag.now i want to invoke the java script of the web page through applet,which i m trying with JSObject,
but I m doing my application in WSAD5.0 ,where i dont have the library for netscape.javascript.*; .so where do i get ths library ?
and this JSObject will work for all the type of browsers ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41104
    
  45
The classes are executed on the client, so the fact that WebSphere does not have these classes doesn't matter. They are part of the Java Plugin, so they are in the browser where the applet runs. As long as the Sun Java Plugin is installed, this should with all current browsers.

In my JDK installation they are in a file called "plugin.jar" in the directory jre/lib.


Ping & DNS - my free Android networking tools app
anil kumar N
Greenhorn

Joined: Mar 22, 2006
Posts: 8
Thanks ULF ,after importing plugin.jar into WSAD ,i m able to import netscape.

I have doubt. Now I am embeding applet in a jsp page,which contains java script( and i am calling this jsp through action class of struts frame work ). Let there is a button named Save on the applet.So when I press save button an action event takes place and in that method i want to call java script of the web page through Live connect (JSObject ) concept.
So in that java script can I submit the form and call action class (struts frame work ).
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41104
    
  45
This page may give you some starting points.
Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
Dear Anil,
you can use JSObject to call javascript, but as far as i am concerned, this would not work under firefox. What you can do is use something like
getAppletContext().showDocument(new URL("javascript:setPropertyBoolean(\"submit\",\"disabled\", false);"));
this will allow you to call any javascript function (whether it is built in or you wrote it) inside the form containing the applet. I would suggest using this script for firefox and the JSObject for IE and netscape.
As for submitting the form, surely you can do that...
simply call the document.formname.submit() javascript function, and it would do that for you
ex: getAppletContext().showDocument(new URL("javascript ocument.formname.submit();"));
Best,
Mohammad
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: communication between applet and javascript
 
Similar Threads
Check for existance of JSObject document
Invoke a method of an applet from another applet in the same page.
javascript and applet communication
Generic Applet
Applet to Javascript Communication