这是我用来提交位于 iframe
中的表单的代码。
<button type="button" id="printbtn" class="mainBtn" onclick="return printReport('frameForm');">Report</button>
function printReport(formName) {
window.frames[formName].document.forms[0].rName.value = reportName;
window.frames[formName].document.forms[0].hXmlFields.value = documentXml;
window.frames[formName].document.forms[0].hCookieName.value = CURRENT_COOKIE_NAME;
window.frames[formName].document.forms[0].submit();
}
<td align=center style="display:inline">
<button type="button" id="printbtn" class="mainBtn" onclick="return printReport('iFrPrintForms');">print </button>
<iframe src="<%= request.getContextPath() %>/jsp/print.jsp" name="iFrPrintForms" frameborder="1" width="0" height="0"></iframe>
</td>
//print.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<body>
<form action="<%= request.getContextPath() %>/PrintForms" method="post" name="submitForm" target="_self">
<input type="hidden" name="rName" value=""/>
<input type="hidden" name="hXmlFields" value=""/>
</form>
</body>
</html>
第一次点击按钮时一切正常,然后 iframe
关闭。
第二次点击它会抛出一个错误:
<块引用>无法获取未定义或空引用的属性“rName”
这仅在 IE11 中发生。问题是什么?对此有什么解决方案?