Calling Java from Javascript: Works in NN, fails in IE 
Author Message
 Calling Java from Javascript: Works in NN, fails in IE

The following script should display an alert if JDK 1.1 is supported by
the browser. This works perfectly in Netscape 4, but fails miserably in
Internet Explorer 4, saying that the "java" object cannot be found.

  <SCRIPT language="JavaScript">
  onerror=null;
  var testObj = java.awt.Toolkit.getProperty("java.vendor","whatever");
  if (testObj)
  {
    alert("JDK 1.1 Supported");
  }
  // -->
  </SCRIPT>

Is there any way to make this work? What is the problem? Does JScript
not  communicate with Java?



Sun, 14 Jan 2001 03:00:00 GMT  
 Calling Java from Javascript: Works in NN, fails in IE
Using java in that way, java.whatever, is not supported in IE to
my knowledge.  I would however like to be proved wrong
because my solution to this problem is a little involved.

Here is how I got around the problem:
Write a java applet that has a public method which returns the
necessary data.
Compile it.
Put the applet tag in your html with height and width set to 0.
Make sure to put it before you use the function.  i believe the browser
will complain about undefined function if you put the applet after
the call to the function.
Then call the applets method by using its name like this:
document.myapplet.somefunc()

Hope this helps
Will

Quote:

>The following script should display an alert if JDK 1.1 is supported by
>the browser. This works perfectly in Netscape 4, but fails miserably in
>Internet Explorer 4, saying that the "java" object cannot be found.

>  <SCRIPT language="JavaScript">
>  onerror=null;
>  var testObj = java.awt.Toolkit.getProperty("java.vendor","whatever");
>  if (testObj)
>  {
>    alert("JDK 1.1 Supported");
>  }
>  // -->
>  </SCRIPT>

>Is there any way to make this work? What is the problem? Does JScript
>not  communicate with Java?



Sun, 14 Jan 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. how java applet in IE call javascript funciton ?

2. HOWTO: Call JavaScript functions from a Java Applet (IE Only)

3. Error handling in Javascript fx (IE and NN)

4. Javascript Heirarchical menu's for IE/NN ?

5. Works for IE, nil for NN

6. External JavaScript OK with IE, not with NN

7. ADSI call works in vbscript fails in jscript

8. ADSI call works in vbscript fails in jscript

9. ADSI call works in vbscript fails in jscript

10. JavaScript to add new contact - works on IE4, fails on PIE

11. Make JavaScript call Java applet method

12. Error in Netscape Calling Java from JavaScript

 

 
Powered by phpBB® Forum Software