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?

  • one
    what applet? drop this thing. oracle in the new jdk even killed them - dirkgntly
  • Join now. If you want to launch from a browser - use Java Web Start. - enzo
  • Looks like you're right. I still suffer with a local disk. And I cannot imagine how to launch an applet from the Web from a user It is necessary to sign, and it is expensive. New oracle security policy killed applets. - vladimir vesely
  • I wanted Java Script to interact with the code. Therefore attached to applets. I see the applet times are over. Through Java WS, you can load any crap, which the browser does not need to work. An applet with limited functionality is not an option. Fucking security. - vladimir vesely

2 answers 2

This is what was cleared up. If you remove the package from the applet code, IE8 will execute the applet’s invoked methods, but ignore the init () method. If you specify a package in the code, and create corresponding folders in the page directory (I have hivasya / chessApplet) and place the class file there, IE8 will execute init () when the page is loaded, then allow other methods to be called, it will do everything right. However, Google Chrome and Opera give an error that setText is not a function, init () is also not executed. For them, the applet is a dummy.

    Line error

     var aplt = document.simpleapp; 

    The document JS object has no simpleapp property. In this case, the value aplt falls into the value undefined which, naturally, does not have the setText method. In this case, you can search for an applet like this:

     var aplt = document.getElementsByName("simpleapp")[0]; 

    But it would be more correct to give it an id and search for a faster method:

     <applet id="simpleapp" ... . . . var aplt = document.getElementById("simpleapp"); 
    • Thanks, but the error is not here. I tried to refer to the applet by name and by identifier. The result is the same. The original version took from the book of David Flanagana "Java Script". I managed to clarify something, but the problem is not solved. - vladimir vesely