当我尝试从applet调用方法时,会出现“对象不支持此属性或方法”

时间:2012-05-03 03:48:45

标签: java javascript html css applet

“对象不支持此属性或方法”从javascript发生,并在行处停止,其中处理从applet调用方法,用于Liferay Portal

javascript片段:

<script type="text/javascript">
    function processSigning(){
        var applet = document.applets["SignApplet"];
        var path_to_certificate = document.getElementById("certificate").value;
        var pass = document.getElementById("password").value;
        var filePath = document.getElementById("documentSign").value;
        applet.filePath = document.getElementById("documentSign").value;

        //at this line, call of method from applet, javascript stops, but applet has this method
        //and it's public
        applet.profileTestPKCS12(path_to_certificate, pass);

        document.getElementById("file").value = applet.getDocumentString(filePath);
        document.getElementById("sign").value = applet.getSignString();
        document.getElementById("cert").value = applet.getCertificateString();
        document.forms['mainForm'].submit();
//        document.getElementById("mainForm").submit();


    }
</script>

html的applet片段:

<APPLET name="SignApplet" mayscript code="SignApplet.class" archive="<%=renderResponse.encodeURL(renderRequest.getContextPath() + "/lib/SignApplet.jar")%>, <%=renderResponse.encodeURL(renderRequest.getContextPath() + "/lib/crypto.tsp.jar")%>, <%=renderResponse.encodeURL(renderRequest.getContextPath() + "/lib/crypto.gammaprov.jar")%>" height=500 width=500 style="display:none;">
    <PARAM name="boxmessage" value="Please wait, while applet is loading">
</APPLET>

2 个答案:

答案 0 :(得分:2)

<APPLET name="SignApplet" ... style="display:none;">

The 'display' property上的W3C。

  

(值)
      该值导致元素不出现在格式化结构中(即,在视觉媒体中,元素不生成框并且对布局没有影响)。后代元素也不会生成任何框; 元素及其内容将完全从格式化结构中删除。

答案 1 :(得分:2)

在applet中你应该避免使用display:none .....当你定义为none时,在visual media中元素不会生成任何框并且对布局没有影响....所以最好尝试 visiblity:hidden 属性而不是 display:none ...