• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help!!- Not able to an Applet method from javascipt - throws error "not a function"

 
Suma Saiprasad
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newbie to javascript and applets. I am stuck with a problem with javascript in netscape 7.0 version(works fine in IE and netscape 4.x) and it would be great if could give me some pointers regarding this.
Let me explain the problem :
I am accessing some functions of an applet in my javascript code as "document.myApplet.Appletfunction()" and this sometimes does not work at all and throws the following javascript error in the Netscape JavaScript Console in 7.0.
"document.StartTimeControl.hasValue() is not a function".( But the function is defined in the applet.)
However this problem is inconsistent and everything works smoothly at times.
I am using java 1.4.2 with the appropriate jpi plugin.

The html code looks like this
--------------------------------
& lt;BODY onlod="init()"& lt;
& lt;SCRIPT LANGUAGE="JavaScript"& lt;
& lt;!-- Begin
function init()
{
if (document.StartTimeControl.hasValue() == false)
{
document.StartTimeControl.setTime(document.formLogfileSearch.StartTime.value);
document.EndTimeControl.setTime(document.formLogfileSearch.EndTime.value);
document.StartDateControl.setDate(document.formLogfileSearch.StartMonth.value,
document.formLogfileSearch.StartDay.value,
document.formLogfileSearch.StartYear.value);
document.EndDateControl.setDate(document.formLogfileSearch.EndMonth.value,
document.formLogfileSearch.EndDay.value,
document.formLogfileSearch.EndYear.value);
}
parent.menu.activate_log_button();
}
// End --& lt;
& lt;/SCRIPT& lt;

.
.
& lt;TABLE CELLPADDING="0" CELLSPACING="0" BORDER="1" WIDTH="96%" rules="none"& lt;
& lt;TR& lt;& lt;TD& lt;
& lt;table border="0" CELLPADDING="0" CELLSPACING="0" width="100%"& lt;
& lt;tr& lt;
& lt;TD& lt;
& lt;APPLET CODE = "MyApplet.class" NAME="MyApplet"
WIDTH="100" HEIGHT="24" ARCHIVE="/myapp/myapplet.jar"& lt;
& lt;/APPLET& lt;
& lt;INPUT TYPE="HIDDEN" NAME="StartTime" VALUE="00:00:00"& lt;
& lt;/td& lt;
& lt;/tr& lt;
& lt;TR& lt;
& lt;TD& lt;
& lt;APPLET CODE = "TimeApplet.class" NAME="EndTimeControl"
WIDTH="100" HEIGHT="24" ARCHIVE="myapplet.jar"& lt;
& lt;/APPLET& lt; 
& lt;INPUT TYPE="HIDDEN" NAME="EndTime" VALUE="23:59:59"& lt;
& lt;/td& lt;
-----------------------------------------------------------------------
Tried with Object Tags and passing "mayscript" param to applet. But this did not work..Can anybody please help!!!
 
Ricardo Monteban
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using the Applet tag, use a combo of the <object> and <embed> tag in your html to load up your applet. Sun has an applet converter tool that will change your applet tag code to the correct code using the object and embed tags.
Afterwards, in Netscape 7.0, look to document.embeds[0] array to find your applet. In IE - you will find your applet installed on the document.applets[0] array. To make sure your applet got loaded properly, do a check of the .length of the arrays....

If both of these are zero's, then your applet isn't loaded ....
Hope this helps,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic