hi
i have the following java applet progam and the javascript
the problem is that when the javascript tries to access the applet method it gives me an error as follows
document.form1. myApplet is null or not an object. plz provide me a soln for this. the code is as
html file
[code=html]<HTML>
<HEAD>
<SCRIPT type="text/javascript">
function getScreenDim() {
alert(document. form1.hello.val ue);
str = document.form1. myApplet.getScr een();
alert(str);
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="form1">
<INPUT type="button" name="hello" value="call JAVA" onClick="getScr eenDim()">
<applet code="javascrip tTest\InJava2" name="myApplet" width="20" height="20">
</applet>
</FORM>
</BODY>
</HTML>[/code]
java file
[code=java]
package javascriptTest;
import java.applet.App let;
import java.awt.Toolki t;
//(IE and Netscape ok)
public class InJava2 extends Applet {
public String getScreenWidth( ) {
return String.valueOf( Toolkit.getDefa ultToolkit().ge tScreenSize().w idth);
}
public int getScreenHeight () {
return Toolkit.getDefa ultToolkit().ge tScreenSize().h eight;
}
public static int getScreen() {
return 25;
}
}[/code]
thanks
mansoor
i have the following java applet progam and the javascript
the problem is that when the javascript tries to access the applet method it gives me an error as follows
document.form1. myApplet is null or not an object. plz provide me a soln for this. the code is as
html file
[code=html]<HTML>
<HEAD>
<SCRIPT type="text/javascript">
function getScreenDim() {
alert(document. form1.hello.val ue);
str = document.form1. myApplet.getScr een();
alert(str);
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="form1">
<INPUT type="button" name="hello" value="call JAVA" onClick="getScr eenDim()">
<applet code="javascrip tTest\InJava2" name="myApplet" width="20" height="20">
</applet>
</FORM>
</BODY>
</HTML>[/code]
java file
[code=java]
package javascriptTest;
import java.applet.App let;
import java.awt.Toolki t;
//(IE and Netscape ok)
public class InJava2 extends Applet {
public String getScreenWidth( ) {
return String.valueOf( Toolkit.getDefa ultToolkit().ge tScreenSize().w idth);
}
public int getScreenHeight () {
return Toolkit.getDefa ultToolkit().ge tScreenSize().h eight;
}
public static int getScreen() {
return 25;
}
}[/code]
thanks
mansoor
Comment