javascript - 求教各位,本地HTML頁面怎么在DIV中嵌套服務(wù)器上的頁面內(nèi)容?不用iframe。
問題描述
報錯信息如下:XMLHttpRequest cannot load http://172.31.71.33/a/mobile/... No ’Access-Control-Allow-Origin’ header is present on the requested resource. Origin ’http://localhost:63343’ is therefore not allowed access.
問題解答
回答1:需要跨域~~https://blog.codefun.cn/blog/...
回答2:你想要嵌套的那個服務(wù)器,得看你有沒有權(quán)限。
只要開啟access-Control-Allow-Origin即可
已PHP為例子
header('Access-Control-Allow-Origin: *');回答3:
提供幾種思路:1)后端渲染2)使用
<p id=showImport></p><IE:Download /><script>oDownload.startDownload(’app.htm’,onDownloadDone);function onDownloadDone(downDate){ document.all.showImport.innerHTML=downDate;}</script>
參考官網(wǎng):https://msdn.microsoft.com/en...
3)使用
<object type='text/x-scriptlet' data='import.htm' width=100% height=30></object>
4)<link rel='import' href='http://www.aoyou183.cn/wenda/myfile.html'>參考:https://developer.mozilla.org...
