Results 1 to 2 of 2
- 07-18-2007, 07:54 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 35
- Rep Power
- 0
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
Here is the code in html page thru which i am invoking the appletJava 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); } }
so when i try to run the applet i am getting the jsexception , but its working with the html pageJava 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>
ThanksJava 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)
- 08-07-2007, 05:46 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks