简体   繁体   English

如何从javascript访问sign applet方法

[英]how to access sign applet method from javascript

I want to access sign applet method from javascript; 我想从javascript访问sign applet方法; hence I create a html file like: 因此,我创建了一个html文件,例如:

html file: html文件:

<script type="text/javascript">
function uploadFileApp(){   
    document.applets[0].FileCooserApp();
    document.uploadAppletFile.FileCooserApp();      
}
</script>
<html>
<h1>Applet Demo</h1>
<body>
<applet name="uploadAppletFile" code="TestApplet.class" archive="FileUpload.jar" width="400" height="300"></applet>
<input type="button" name="button" onclick="uploadFileApp();" value="Button"/>
</body>
</html>

Applet Class: Applet类别:

public class TestApplet extends JApplet{
    public TestApplet() {
    }   
    public String FileCooserApp(){
        JFileChooser chooser = new JFileChooser();
        chooser.showOpenDialog(null);
        File file = chooser.getSelectedFile();
        String path = file.getAbsolutePath();
        return path;
    }   
 }

as I shown in my html file I used both way to access applet method but when i click on button nothing action going to perform. 正如我在html文件中显示的那样,我使用了两种方法来访问applet方法,但是当我单击按钮时,什么动作都不会执行。 and console shows nothing. 和控制台什么也没显示。

all in html 全部用HTML

<object id="uploadAppletFile"
   classid="java:com/company/package/TestApplet.class"
   type="application/x-java-applet" 
   archive="FileUpload.jar"  
   height="0" width="0">
   <param name="code" value="com/company/package/TestApplet.class" /> 
   <param name="archive" value="FileUpload.jar" />
</object> 




<script type="text/javascript">
function uploadFileApp(){   
    uploadAppletFile.FileCooserApp();
}
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM