Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JavaScript Calling a Java Function Doesn't Work in Safari



if i recall correctly, this was called LiveConnect (http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/ livecon.htm). but it never panned out. only works on mozilla. guess if some people won't play nice (er, um, micro what's their name), then it's hard to get a technology accepted. though, could this be accomplished by say, php?

rob


On Sunday, October 26, 2003, at 08:42 AM, Steven Weintraut wrote:

I am going nuts with this. Perhaps I'm showing my increasing age? I'm pretty good with C, JavaScript, AppleScript, etc, but after 20 years of non-java programming I decided to spruce up a heavily javascripted filemaker-based web site with some calls to some java functions I just started writing.

the problem is, I can't get JavaScript to call my Java applet.

I was finally able to get it to work via Mozilla on windows XP, but no other browser/platform combination will work.

Really, the combo's I need to support are Safari on the Mac, and Explorer on the PC side

But neither of those work at all............

Here is the sample HTML and sample Java, it's about as simple as it possibly could be..........

Being that all I want to do is call a Java function via JavaScript and get a return value, I was hoping I could use the built-in VM of whatever browser the user is using, but after spending the last 3 days googling through the net and browsing every java book at the local book store, I'm about ready to rip the hair out of my head.

This would seem to be a simple thing to want to do, but yet, it doesn't seem to work except in Mozilla Win32

I tried a Sun HTML convertor that converted my applet tag to what was suppose to be a cross platform object/embed tag, but that didn't work either.

HTML Code
------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>Simple Applet Example</TITLE>
<SCRIPT>
function GetName()
{	
	var myApplet=document.getElementById("FMLinker")
	alert(myApplet.name)	
	alert(myApplet.GetData())
}

</SCRIPT>
</HEAD>
<BODY>
<applet code="FMLinker.class" name="FMLinker" width=300 height=150 id="FMLinker" scriptable="true" mayscript="true">
Your browser does not support Java, so nothing is displayed.
</applet>
<form name="myForm" method="post" action="">
<input type="button" name="Button" value="Button" onClick="GetName()">
</form>
</BODY>
</HTML>


Java Code (i stripped out a bunch of code just to get to the simplest case)
----------------------------------------------------------------------- -----------------------------


import java.applet.*;
import java.net.*;
import java.awt.*;
import java.sql.*;

public class FMLinker extends Applet
{
    public void init()
    {
         System.out.println("Hello, Java!");
         System.out.println(GetData());
    }

public String GetData()
{
String myResultString="haha";
return myResultString;
}
}
_______________________________________________
web-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/web-development
Do not post admin requests to the list. They will be ignored.
_______________________________________________
web-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/web-development
Do not post admin requests to the list. They will be ignored.

References: 
 >JavaScript Calling a Java Function Doesn't Work in Safari (From: Steven Weintraut <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.