使用JavaScript在另一个本地html中获取本地html [英] Getting local html inside another local html with JavaScript
问题描述
我的PC中有一个用于工作的html文件,我想向其中加载另一个本地html文件,我希望将其加载到一个div中. <div id="loadHere"></div>
I have got one html file in my PC that I use for work and I want to load another local html file to it, I want it to be loaded inside one div. <div id="loadHere"></div>
我使用了这个jquery函数,但是它不起作用$("#loadHere").load("001.html")
I used this jquery function but it's not working $("#loadHere").load("001.html")
当我这样做时,我会收到此错误:
When I do that I get this error:
XMLHttpRequest cannot load file:///C:/Users/**censored**/Desktop/**censored**/html/00.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
jquery.min.js:132 Uncaught TypeError: Cannot read property 'responseText' of null
我知道这样做是出于安全考虑,因此似乎没有安全的方法将其关闭(例如,对于一个文件夹).
I understand that this is done because of security and there is propably no safe way to turn it off (for example for one folder).
所以我在考虑替代解决方案,如果我在主html文件上有一些拖放空间,那我可以将要加载的本地html文件拖放到<div id="loadHere"></div>
里面,该怎么办?
So I was thinking about alternative solution, what if I had some drag&drop space on my main html file, where I could just drag and drop local html file that I want to load inside <div id="loadHere"></div>
.
有可能吗?如果是,我应该从哪里开始?是否有一些框架?我的想法是,将文件拖放到拖放区域后,它会保存在某个变量中,有了该变量,将其真正轻松地加载到该div中即可.
Is that possible? If yes, where should I start? Is there some framework for that? My idea was that after I would drop that file on drag&drop area it would get saved in some variable and with that variable it would be really easy to load it inside that div.
谢谢,祝你有美好的一天.
Thanks and have a nice day.
推荐答案
在Chrome/chrome浏览器中,尝试将启动器调整为
At chromium / chrome browsers , try adjusting launcher to
铬
/path/to/chromium-browser --allow-access-from-files
chrome
/path/to/google-chrome --allow-file-access-from-files
请参见
如何我如何将Google Chrome浏览器的标志"--allow-file-access-from-files"永久保存?
这篇关于使用JavaScript在另一个本地html中获取本地html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!