File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes With Java Plug-in, document.applets.length returns 0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "With Java Plug-in, document.applets.length returns 0 " Watch "With Java Plug-in, document.applets.length returns 0 " New topic
Author

With Java Plug-in, document.applets.length returns 0

Carina Svensson
Greenhorn

Joined: Jul 03, 2002
Posts: 9
Hi all!
I need to use Java Plug-in, because I use the Swing-package.
When I let my browser, Netscape 4.78, use the Java Plug-in in j2re1.4.1, then JavaScript believe that the appletvector is empty.
I have tested to let JavaScript call methods of an applet that only extends Applet. It worked fine when the Java Plug-in wasn't used (and the appletvector has length 1).
How can I make JavaScript call (swing)applet methods, when my browser is using the Plug-in?
Thanks in advance for your help!
Carina
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

myself, i stick to Java 1 for applets. do you really need swing?
good luck


SCJP
Visit my download page
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I think you are using JRE 1.3.1 or higher. In this Version you can choose the Browser. If you select a Browser, this Browser ignores the default java-classes and uses the new once.
In this case "normal" Applet won't work. If you don not select any Browser, jre 1.3.1 is only used when needed.
If you unselect your Browser in the JRE-Configurator and the close all your Browsers and restart it again, the error will be fixed.
J�rn
Carina Svensson
Greenhorn

Joined: Jul 03, 2002
Posts: 9
I'm implementing in Swing, because I heard that this package has a lot of improvements compared to the awt package. Now I have implemented a lot in Swing, but only used the appletviewer.
I could never imagine that using Swing could bring me in to such trouble.
I think I need Netscape 6(or Internet Explorer 4 or higher) to make JavaScript scripting a swingapplet.
Carina
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
sorry, now I understand your question:
you have to use this params:
<PARAM NAME = "MAYSCRIPT" VALUE = "true" >
<PARAM NAME="scriptable" VALUE="true">
Then you can call your JApplet from javascript.
Off course you can't use the Applet tag. Use this:

<OBJECT codetype="application/java" NAME="yourName"
WIDTH = 450 HEIGHT = 250 classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
<PARAM NAME = NAME VALUE = "yourName" >
<PARAM NAME = CODE VALUE = "yourClass.class" >
<PARAM NAME = ARCHIVE VALUE = "yourArchive.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3.0">
<PARAM NAME = MAYSCRIPT VALUE = true >
<PARAM NAME="scriptable" VALUE="true">


<!--Netscape--><EMBED NAME="yourName" MAYSCRIPT=true scriptable=true type="application/x-java-applet;version=1.2" java_CODE = "yourClass.class" WIDTH = 350 HEIGHT = 250 pluginspage="http://java.sun.com/products/plugin/1.2/plugin-install.html"></EMBED>
</OBJECT>
Carina Svensson
Greenhorn

Joined: Jul 03, 2002
Posts: 9
Hello J�rn!
I tried to do as you wrote and some other ways, but it still doesn't work(applet array is still empty).
After reading this page:
http://java.sun.com/j2se/1.4/docs/guide/plugin/developer_guide/js_java.html
I believe that the only way to to solve the problem is to install Netscape 6.
Carina
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: With Java Plug-in, document.applets.length returns 0