NOTE: On IE4 or better, you can't call java.lang.* methods directly from Javascript or Jscript. IE javascript can only access the public methods of an applet (a class derived from java.applet.Applet) but don't have a general access to other java classes . So the solution is simple, wrap the java.lang.* call in a public method of a "dummy" Applet.
import java.awt.*;
import java.applet.*;
// to be called from javascript (IE and Netscape ok)
public class inJava extends Applet{
public integer getScreenWidth() {
return Toolkit.getDefaultToolkit().getScreenSize().width);
}
public integer getScreenHeight() {
return Toolkit.getDefaultToolkit().getScreenSize().height);
}
}
[Javascript and HTML (IE and Netscape)] <HTML><HEAD></HEAD><BODY>
<SCRIPT>
function getScreenDimension() {
alert("Screen Dimension\r\n width:" +
document.myApplet.getScreenWidth() +
" height:" +
document.myApplet.getScreenHeight() );
}
</SCRIPT>
<FORM>
<INPUT type="button" value="call JAVA"
onClick = "getScreenDimension()">
</FORM>
<APPLET CODE="inJava.class"
NAME="myApplet"
HEIGHT=100 WIDTH=100>
</APPLET>
</BODY></HTML>
NOTE: This for demonstration only. On N4 or IE4, it's better to use screen.height and screen.width properties directly. There is no need for a Java Applet!