Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...What you have done for people like me is immeasurably helpful."

Geography

Where in the world do Tek-Tips members come from?

java javascript communication

wduty (Programmer)
17 Aug 00 1:01
This is really basic stuff. I am trying to call a method in an applet from a javascript. The applet method just returns a string. It works fine. It's simple. It took five minutes. HOWEVER, it works in every browser except one: Internet Explorer 5.0 on a Macintosh. I can't figure out why.

HTML applet code:
--------------------------
<applet code="excerpt.class" width="274" height="181" name=theapplet></applet>


javascript function:
--------------------------
function callJava()
{
var test = document.theapplet.test()
document.theform.thefield.value=test;
}


applet method:
--------------------------
public String test()
{
String returnStr = "";
for (int j=0; j<15;j++)
{
for (int i=0; i<15;i++)
{
if (theArray[ i ][j])
{
returnStr += 1;
}
else {returnStr += 0;}
}
}
return returnStr;
}


Anyone? Anyone?

--Will Duty
wduty@radicalfringe.com

ackka (Programmer)
18 Aug 00 16:05
My guess is that it has to do with the fact that the Document Object Model changes per operating System and browser.  Take a look at www.htmlguru.com and the curious_eye tutorial on how to build cross platform cross browser code for javascript and dhtml.  I can post the code if you cannot figure it out :)  One other thing , it should be possible to call javascript functions from the applet.  Applets can call functions by the use of the URL class, send me an email if your interested and i can send you then code...

later

ackka
tmoses@iname.com
my site
"Do No Harm, Leave No Tracks"
ICMP Summer 2000, 2600 Article

wduty (Programmer)
18 Aug 00 16:39
Thanks for the response. I actually solved the problem another way.

I was trying to get a value from the applet to a form field in the HTML page using javascript. What I did instead was to get rid of the HTML form altogether submit the page from the applet directly using appletContext:

try
    {url = new URL("http://www.blah.com/page.asp?gifpixels="+test()+"&name="+name.getText()+"&ID="+getParameter("ID"));}
catch (MalformedURLException e) { }
getAppletContext().showDocument(url,"_parent");


Works OK. This way I'm just sending the values in a querysring. It's simpler and less hacky though it could probably still be better some way or other. As for crossplatform DHTML code there's not really any DHTML going on here but I have a few questions about that regarding another problem. I'll email you.

--Will Duty
wduty@radicalfringe.com

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close