一個頁面有多個iframe找不到結果的問題

來源:互聯網
上載者:User

標籤:iframe

        前面介紹過iframe,也介紹過跨域請求,這裡就不再贅述了。

        今天在實際的業務中碰到了一個現象,一個erp管理系統,用到了上傳圖片和iframe訪問其他的網域名稱的情況,上傳圖片用到了ajaxfileupload,而這個上傳圖片的控制項本身就有iframe,也就是說導致了一個頁面中有2個iframe,導致我上傳圖片想返回操作結果的時候返回不到任何結果,例如

前台訪問調用的方法

$.ajaxFileUpload({            url : ‘http://*******.com/active/addImg.action‘, // 需要連結到伺服器位址            secureuri : false,            fileElementId : ‘imgFile‘, // 檔案選擇框的id屬性            cache :false,            dataType: ‘json‘,//傳回值類型 一般設定為json              success : function(result,status) {                                }                    })

後台接收並返回

       

Result result=    activeService.addImg(getImgFile(), getImgFileFileName());print(result.resultJson());

無論調用多少次都無法返回結果,之後上網查詢原因,才知道,在多個iframe中,返回結果的domian需要指定,後來在返回結果寫成

Result result=    activeService.addImg(getImgFile(), getImgFileFileName());print("<script>document.domain = ‘******.com‘;</script>"+result.resultJson());

結果就能正常顯示了!!!

本文出自 “精忠報國” 部落格,謝絕轉載!

一個頁面有多個iframe找不到結果的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.