[英]Resolving IFRAME cross origin issue without having access to server side
When I am trying to open an IFRAME in another domain当我尝试在另一个域中打开IFRAME时
I got the following JavaScript error in firefox我在Firefox中收到以下JavaScript错误
Error: Permission denied to access property 'document'错误:拒绝访问属性“文档”的权限
and in Chrome displaying the following error并在Chrome中显示以下错误
Uncaught DOMException: Blocked a frame with origin "http://mlocal.192.168.178.91" from accessing a cross-origin frame.(…)未捕获到的DOMException:阻止了源为“ http://mlocal.192.168.178.91”的帧访问跨域帧。(…)
Note: We don't have access to change the headers in server side.注意:我们无权更改服务器端的标头。
The below mentioned is the parent page,下面提到的是父页面,
<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>
Clinical Form Servlet code is below(Child page)以下是临床表格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>
If I wanted to clear the child page content using the below mentioned script got the above mentioned error.如果我想使用下面提到的脚本清除子页面内容,则会收到上面提到的错误。
function clearForm(){ window.frames['tabImages'].document.forms[0].ProgressNote.value=""; }
Please give me a suggestion请给我一个建议
When I am trying to open an IFRAME in another domain当我尝试在另一个域中打开IFRAME时
I got the following JavaScript error in firefox我在Firefox中收到以下JavaScript错误
Error: Permission denied to access property 'document'错误:拒绝访问属性“文档”的权限
and in Chrome displaying the following error并在Chrome中显示以下错误
Uncaught DOMException: Blocked a frame with origin "http://mlocal.192.168.178.91" from accessing a cross-origin frame.(…)未捕获到的DOMException:阻止了源为“ http://mlocal.192.168.178.91”的帧访问跨域帧。(…)
Note: We don't have access to change the headers in server side.注意:我们无权更改服务器端的标头。
The below mentioned is the parent page,下面提到的是父页面,
<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>
Clinical Form Servlet code is below(Child page)以下是临床表格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>
If I wanted to clear the child page content using the below mentioned script got the above mentioned error.如果我想使用下面提到的脚本清除子页面内容,则会收到上面提到的错误。
function clearForm(){ window.frames['tabImages'].document.forms[0].ProgressNote.value=""; }
Please give me a suggestion请给我一个建议
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.