Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-18-2007, 08:54 PM
Member
 
Join Date: Jul 2007
Posts: 35
silvia is on a distinguished road
Help with JSobject from the netscapte
Hi, I am workig in a project on javascript. For which i need java and javascript communication.
I am working with JSobject from the netscapte and i am getting worked in one way.
When i am invoking the applet thru webpage i am getting the applet methods working with javascript and when i try to acess the javascript or object for getting the webpage contents i am getting the jsexception

here is the applet code i am using
Code:
import netscape.javascript.*; import java.applet.*; import java.awt.*; public class MyApplet extends Applet { /** * */ private static final long serialVersionUID = 1L; public void init() { JSObject win = JSObject.getWindow(this); JSObject doc = (JSObject) win.getMember("document"); JSObject loc = (JSObject) doc.getMember("location"); win.call("f", null); // Call f() in HTML page } public void wish() { JSObject win = JSObject.getWindow(this); JSObject doc = (JSObject) win.getMember("document"); JSObject loc = (JSObject) doc.getMember("location"); Object[] args ={ "hello from java"}; win.call("doit",args); } }
Here is the code in html page thru which i am invoking the applet
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <applet id="Calculator" width="300" height="500" code="MyApplet.class" codebase="." MAYSCRIPT> <param name="InitialMode" value="Normal"> </applet> <HTML> <SCRIPT language="JavaScript"> function f() { alert("hello world"); } function doit(msg) { alert("entered do it "); //var msg = document.Calculator.wish; alert(msg); } function startJSFractal() { document.calculator.init(); } </SCRIPT> <BODY> <form name="Form1"> <!--<OBJECT ID="Fractal" WIDTH=500 HEIGHT=120 CLASSID="CLSID:8AD9C840-044E-11d1-B3E9-00805F499D93" <PARAM NAME="code" value="MyApplet.class"> <PARAM NAME="codebase" value="1.0.2"> <PARAM NAME="level" value="5"> </OBJECT>--> <input type="button" name="Button1" value="Start" onClick="document.Calculator.wish()" language="JavaScript"> </BODY> </HTML>
so when i try to run the applet i am getting the jsexception , but its working with the html page
Code:
netscape.javascript.JSException at netscape.javascript.JSObject.getWindow(JSObject.java:144) at MyApplet.init(MyApplet.java:14) at sun.applet.AppletPanel.run(AppletPanel.java:378) at java.lang.Thread.run(Thread.java:595)
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 06:46 AM
Member
 
Join Date: Jul 2007
Posts: 40
barney is on a distinguished road
After all at it's very beginning (LiveScript was it's maiden name, if I remember well) javascript developed by Netscape supposed exactly to make a communication "bus" between the client-side state and the Java language/applets (the moment Netscape decided to have a partnership with Sun).
Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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

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



All times are GMT +3. The time now is 07:25 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org