「對象不支持此屬性或方法」時發生「對象不支持此屬性或方法」,並在行中停止,並在此處進行方法調用來自小程序,對於Liferay門戶當我嘗試從小應用程序調用方法
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 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>
在哪一行發生錯誤? – sgowd
在這個「applet.profileTestPKCS12(path_to_certificate,pass);」 – test1604
這可能聽起來很愚蠢,但爲了防止這些問題,我通常會驗證該對象是否存在。就像:if(document.applets [「SignApplet」]){//做stuf。 。 。} –