aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes prolem while calling javascript method from applet in Netscape6.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "prolem while calling javascript method from applet in Netscape6.2" Watch "prolem while calling javascript method from applet in Netscape6.2" New topic
Author

prolem while calling javascript method from applet in Netscape6.2

Venkata Ramana
Greenhorn

Joined: Feb 14, 2002
Posts: 17
I am trying to call javascript method in java(in my applet)
here i wrote the jsp page and i used
<jsp lugin> tag for applet. This is working fine with IE6.0 and Netscape4.6. but with the latest version of Netscape(6.2) i am getting the following exception
netscape.javascript.JSException: JSObject.getWindow() requires mayscript attribute on this Applet at java.lang.reflect.Constructor.newInstance(Native Method) at sun.plugin.liveconnect.PrivilegedConstructObjectAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)at sun.plugin.liveconnect.SecureInvocation.ConstructObject(Unknown Source)
I am adding my applet code and jsp code.
In my applet there is button, by clicking the button it will calls the javascript method and closes the browser window.
Applet class:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import netscape.javascript.JSObject;
import netscape.javascript.*;
import javax.swing.colorchooser.AbstractColorChooserPanel;

public class JSoTest extends JApplet implements ActionListener
{
JButton btn;
JPanel p1;
Color clr;
public JSoTest()
{
init();
}
public void init()
{
btn=new JButton("Close");
btn.addActionListener(this);
clr=Color.green;
p1=new JPanel();
this.getContentPane().setLayout(new BorderLayout());
getContentPane().add(p1,"Center");
getContentPane().add(btn,"South");
p1.setBackground(clr);
}
public void actionPerformed(ActionEvent e)
{
try{
JSObject obj=JSObject.getWindow(this);
obj.call("close",null);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

jsp page:

<html>
<head>
</head>
<body >
<jsp lugin type="applet" code="JSoTest.class" codebase="/examples/jsp/plugin/applet/"
jreversion="1.3"
iepluginurl="http://java.sun.com/products/plugin/1.3/plugin-install.html"
nspluginurl="http://java.sun.com/products/plugin/1.3/plugin-install.html"
width="200" height="150" name="Fractal">
<jsp arams>
<jsp aram name="MAYSCRIPT" value="true" />
</jsp arams>
<jsp:fallback>
<p>Unable to load java plugin</p>
</jsp:fallback>
</jsp lugin>

</body>
</html>
If i write the html file and with embed tag it is working fine.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

A Google search on "+java +applet +mayscript +javascript" gave me this as the first match:
http://java.sun.com/products/plugin/1.3/docs/jsobject.html
Just search the page for 'mayscript'.
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prolem while calling javascript method from applet in Netscape6.2
 
Similar Threads
Problem while Invoking Applet's method from javascript
Java Plug-in misbehaives
Problem while Invoking Applet's method from javascript
problem of applet in Netscape 6.2 while usinf JSObject
problem of JSObject in Netscape6.2