繁体   English   中英

解决IFRAME跨源问题,而无需访问服务器端

[英]Resolving IFRAME cross origin issue without having access to server side

当我尝试在另一个域中打开IFRAME时

我在Firefox中收到以下JavaScript错误

错误:拒绝访问属性“文档”的权限

并在Chrome中显示以下错误

未捕获到的DOMException:阻止了源为“ http://mlocal.192.168.178.91”的帧访问跨域帧。(…)

注意:我们无权更改服务器端的标头。

下面提到的是父页面,

 <table> <tr> <td><img src="../images/cancelbutton.jpg" name="cancelbutton" class='button1' onclick="clearForm();" /> <img src="../images/savebutton2.jpg" name="savebutton" class='button1' onclick="savSubForm();" /></td> </tr> <tr> <td> <IFRAME SRC="http://192.168.178.91:8080/his/ClinicalFormServlet?action=CDOC-OPEN_A_DOCUMENT&patientId=400168&visitId=920834&formName=IP_Progress_Note_Child&ParentdocType=IPR&formType=2&encounterId=&parentFormName=IP_Progress_Note_Main&parentDocumentId=708996&isEmbeddedForm=true&embeddedFormName=IP_Progress_Note_Child" NAME="tabImages" id="tabImages" frameborder="0" hspace="0" vspace="0" WIDTH="650" HEIGHT="160" SCROLLING="NO"> </IFRAME> </td></tr> </table>

以下是临床表格Servlet代码(子页面)

 <table width='100%' cellspacing='0' cellpadding='0' border='0' class="textareatable"> <tr> <td> <textarea name="ProgressNote" rows="4" cols="85" class="clinical_textArea" ></textarea> </td></tr> </table>

如果我想使用下面提到的脚本清除子页面内容,则会收到上面提到的错误。

 function clearForm(){ window.frames['tabImages'].document.forms[0].ProgressNote.value=""; }

请给我一个建议

当我尝试在另一个域中打开IFRAME时

我在Firefox中收到以下JavaScript错误

错误:拒绝访问属性“文档”的权限

并在Chrome中显示以下错误

未捕获到的DOMException:阻止了源为“ http://mlocal.192.168.178.91”的帧访问跨域帧。(…)

注意:我们无权更改服务器端的标头。

下面提到的是父页面,

 <table> <tr> <td><img src="../images/cancelbutton.jpg" name="cancelbutton" class='button1' onclick="clearForm();" /> <img src="../images/savebutton2.jpg" name="savebutton" class='button1' onclick="savSubForm();" /></td> </tr> <tr> <td> <IFRAME SRC="http://192.168.178.91:8080/his/ClinicalFormServlet?action=CDOC-OPEN_A_DOCUMENT&patientId=400168&visitId=920834&formName=IP_Progress_Note_Child&ParentdocType=IPR&formType=2&encounterId=&parentFormName=IP_Progress_Note_Main&parentDocumentId=708996&isEmbeddedForm=true&embeddedFormName=IP_Progress_Note_Child" NAME="tabImages" id="tabImages" frameborder="0" hspace="0" vspace="0" WIDTH="650" HEIGHT="160" SCROLLING="NO"> </IFRAME> </td></tr> </table>

以下是临床表格Servlet代码(子页面)

 <table width='100%' cellspacing='0' cellpadding='0' border='0' class="textareatable"> <tr> <td> <textarea name="ProgressNote" rows="4" cols="85" class="clinical_textArea" ></textarea> </td></tr> </table>

如果我想使用下面提到的脚本清除子页面内容,则会收到上面提到的错误。

 function clearForm(){ window.frames['tabImages'].document.forms[0].ProgressNote.value=""; }

请给我一个建议

暂无
暂无

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

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