解決的方法:
1.在 ueditor/dialogs/internal.js 加入 document.domain = '根域名';
2.在當(dāng)前頁(yè)面同樣指定根域名:
<script type="text/javascript">
document.domain = "根域名";
</script>
這樣在 chrome、firefox 下沒有問題,但在 ie 下還需要簡(jiǎn)單修改下 UEditor,在 editor.js 中找到:
this._setup( container.firstChild.contentWindow.document );
在它上邊加入下邊的代碼:
if (ie) {
document.getElementById('baidu_editor_' + this.uid).src = "javascript:(function(){document.open();document.domain='"+document.domain+"';document.close();})()";
}
接下來找到:
me.document = doc;
在它下邊加入:
me.document.domain='根域名';
到這里就解決了 UEditor 跨域傳圖片的問題,希望對(duì)大家有所幫助。
作者:東奎