Win 7, installed java ire, jdk. In the java control panel -> security entered the local disk in the list of exceptions. IE seems to have allowed active content. Page Code:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <h1>Applet example</h1><hr></br></br></br> <div id="appletdemo"> </div></br> <button name="callApp" onclick="sendNdisplay()">call applet</button> <applet name="simpleapp" code="SimpleApplet.class" width="300" height="100"></applet> <SCRIPT type="text/javascript" src = "engine.js"></SCRIPT> </body> </html>
Script code:
var s = "The text to and from applet"; var panel = document.getElementById("appletdemo"); var aplt = document.simpleapp; function sendNdisplay() { var setok = aplt.setText(s); var responce = aplt.getText(); panel.innerHTML = responce; }
Applet Code:
package hivasya.chessApplet; import java.applet.Applet; public class SimpleApplet extends Applet { String s; public boolean setText(String text) {s = text; } public String getText() {return s; } } // end class
Compiled with two methods, from the command line (javac) and using Eclipse. The class file is placed in the directory where the html page and javascript. IE writes: the object does not support this property or method. And points to the line where the set method is called. Opera writes:
Can not read property 'setText' of undefined.
I tried to create the init method in the applet and paint the rectangle with the background color. No reaction. Why do browsers perceive an applet as a dummy?