简体   繁体   中英

Resolving IFRAME cross origin issue without having access to server side

When I am trying to open an IFRAME in another domain

I got the following JavaScript error in firefox

Error: Permission denied to access property 'document'

and in Chrome displaying the following error

Uncaught DOMException: Blocked a frame with origin "http://mlocal.192.168.178.91" from accessing a cross-origin frame.(…)

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)

 <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

I got the following JavaScript error in firefox

Error: Permission denied to access property 'document'

and in Chrome displaying the following error

Uncaught DOMException: Blocked a frame with origin "http://mlocal.192.168.178.91" from accessing a cross-origin frame.(…)

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)

 <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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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