aspose file tools*
The moose likes Applets and the fly likes Communication Java-Javascript with plug-in Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Communication Java-Javascript with plug-in" Watch "Communication Java-Javascript with plug-in" New topic
Author

Communication Java-Javascript with plug-in

xavier gagneur
Greenhorn

Joined: Jul 26, 2001
Posts: 3
Hi,
I am currently trying to communicate with applet and JavaScript
See my source code please and help me, I do't understand why it crash in IE with plig in Java 1.3.1
Many Thanks
x.
///////////////////
//HTML SOURCE
<html>
<HEAD>
<SCRIPT code="JavaScript">
function writeHtml(nbr){
document.writehtml.writeHtml(nbr);
};
</SCRIPT>
</HEAD>
<BODY>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="300" height="300" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win.cab#Version=1,3,0,0"
name="writehtml">
<PARAM NAME=CODE VALUE=HtmlWriter>
<PARAM NAME="codebase" VALUE=".">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="true">
<PARAM NAME="MAYSCRIPT" VALUE="true">
</OBJECT>
<FORM name="resto">
Nombre de lignes a g�n�rer : <input name="result" type="text" value="5"><BR>
<input type="button" onclick="javasript:writeHtml(document.resto.result.value)" value="OK">
</FORM>
</BODY>
</HTML>
//////////////////////
//JAVA JAPPLET SOURCE
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import netscape.javascript.*;
public class HtmlWriter extends JApplet{
JSObject win = null;
public void paint(Graphics g){
g.setColor(Color.black);
g.drawString("APPLET RUN...", 15,35);
}

public void writeHtml(String Nombre){
win.eval("alert('TEST2');"); // CRASH HERE!!!
}
public void init(){
win = JSObject.getWindow(this); //OK
win.eval("alert('TEST');"); //No PROBLEMES HERE
repaint();
}
}
Charlie Boss
Ranch Hand

Joined: May 22, 2001
Posts: 44
i don't know about using eval.. but this is how i call show an alert..
Object[] arguments = {"test"};
arguments[0] = "No Information retrieved from database.";
win.call("alert", arguments);

Java Rawks
xavier gagneur
Greenhorn

Joined: Jul 26, 2001
Posts: 3
Originally posted by Charlie Boss:
i don't know about using eval.. but this is how i call show an alert..
Object[] arguments = {"test"};
arguments[0] = "No Information retrieved from database.";
win.call("alert", arguments); // KRASH HERE

Hi Charlie,
That is the same problem when I use the win Object in applet
with the Java plug-in!
If i use the applet tag in HTML, that's OK but with the Object tag to use the plug-in it always crash IE.So I can't use JSObject
+win.call --> CRASH
+win.eval --> CRASH
+win.getMember(..) --> CRASH
But I don't know why it's work fine in the init methode.
If you can use JSObject with the plug-in help me please.
x.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Communication Java-Javascript with plug-in