Dexters February 2016

JavaScript error when importing a package

getting the following error when importing netscape.javascript

importClass(netscape.javascript)

org.mozilla.javascript.EcmaError: ReferenceError: "netscape" is not defined.

Trying to use javascript within applet to get access to cookies. Using the following as an example to import required package

http://www.java2s.com/Code/Java/JDK-6/UsingJavaObjectsinJavaScript.htm http://docs.oracle.com/javase/tutorial/deployment/applet/invokingJavaScriptFromApplet.html

Answers


Dexters February 2016

Found out by trial and error.

It seems we need to prefix with Packages

importPackage(Packages.netscape.javascript);

Post Status

Asked in February 2016
Viewed 3,385 times
Voted 4
Answered 1 times

Search




Leave an answer