javascript - 求教各位,本地HTML页面怎么在DIV中嵌套服务器上的页面内容?不用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:你想要嵌套的那个服务器,得看你有没有权限。
只要开启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>
参考官网:https://msdn.microsoft.com/en...
3)使用
<object type='text/x-scriptlet' data='import.htm' width=100% height=30></object>
4)<link rel='import' href='https://www.haobala.com/wenda/myfile.html'>参考:https://developer.mozilla.org...
