-
Java/Javascript
I wanna create a simple Java/javascript applet.
I mean: An Java-applet who can call a javascript function in his html document.
HTML-document:
Code:
<html>
<head>
<script type="text/javascript">
function theJFunction()
{
alert("Hello world");
}
</script>
</head>
<body>
<applet code="myApplet" width="500" height="500"></applet>
</body>
</html>
Applet:
Code:
public class myApplet extends java.applet.Applet
{
public void init()
{
//here to call the javascript function "theJFunction()"
}
}
How can I call the javascript function from my applet?
-
-
I've allready seen that document but when I do Code:
getAppletContext().showDocument
(new URL("javascript:doAlert(\"" + msg +"\")"));
}
The page goes to another URL, I mean the browser thinks the page goes to another URL.
And than I can't use the javascript command "onbeforeunload".
For the JSObject I don't have the libraries, and I can't find where to download them.
-
In order to start using JSObject you need to import netscape.javascript.JSObject
Add plugin.jar to the classpath of you project, netscape is there.
Plugin.jar can be found in jre6 folder