簡體   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