简体   繁体   English

Chrome 上的 access-control-allow-origin 不允许 Origin null

[英]Origin null is not allowed by access-control-allow-origin on Chrome

I'm developing a website to be used from a DVD, so I cannot rely on http:// protocol.我正在开发一个要从 DVD 使用的网站,所以我不能依赖http://协议。 The HTML pages use jQuery and knockout.js and load data from the JSON file using $.getJSON . HTML 页面使用jQuery 和knockout.js,并使用$.getJSON从JSON 文件加载数据。

This runs fine on Firefox but I get an origin null is not allowed by access-control-allow-origin on Chrome.这在 Firefox 上运行良好,但我在 Chrome 上的origin null is not allowed by access-control-allow-origin I've looked many SO answers on this but I cannot force the users to start Chrome using additional command line parameters or putting the site on HTTP web server.我已经看过很多关于此的 SO 答案,但我无法强制用户使用其他命令行参数或将站点放在 HTTP Web 服务器上来启动 Chrome。

Is there a way to let Chrome open local files?有没有办法让 Chrome 打开本地文件?

I know this might be late, but I in the mist of a similiar problem.我知道这可能会迟到,但我陷入了类似问题的迷雾中。 I have a solution for JSON (which I will share), but not for XML.我有一个针对 JSON 的解决方案(我将分享),但没有针对 XML 的解决方案。

My solution was to use a javascript loader (ex: HeadJS) which does a great job for an application needing to run offline.我的解决方案是使用 javascript 加载器(例如:HeadJS),它对于需要离线运行的应用程序非常有用。 I would create a file with .js in this manner.我会以这种方式用 .js 创建一个文件。

var JSON = {
    Field1: "Text",
    Field2: "Text2"
} 

Then I would use the loader.然后我会使用装载机。 We actually allowed the user to choose which data they wanted and loaded that particular file.我们实际上允许用户选择他们想要的数据并加载该特定文件。

Hope this help someone else.希望这对其他人有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kubernetes Nginx上传大文件400否'Access-Control-Allow-Origin' - Kubernetes Nginx upload large file 400 No 'Access-Control-Allow-Origin' 使用httpclient和formdata的请求资源上不存在“ Access-Control-Allow-Origin”标头 - No 'Access-Control-Allow-Origin' header is present on the requested resource with httpclient and formdata 如何在Yesod中为静态文件启用“Access-Control-Allow-Origin”标头? - How do I enable 'Access-Control-Allow-Origin' headers for static files in Yesod? 角度文件上传到Laravel。 请求的资源上不存在“ Access-Control-Allow-Origin”标头 - Angular file upload to Laravel. No 'Access-Control-Allow-Origin' header is present on the requested resource Threejs Model 正在加载:“访问 XMLHttpRequest .. 来自原 'null' 的访问已被 CORS 策略阻止”- 如何在本地测试? 还是简单上传? - Threejs Model Loading: “Access to XMLHttpRequest .. from origin 'null' has been blocked by CORS policy” - How to Test Locally? Or Simple Upload? 谷歌浏览器 - 禁用Chrome Beta 8的文件访问文件 - Google Chrome --allow-file-access-from-files disabled for Chrome Beta 8 启动 Chrome 应用程序时可以使用“--allow-file-access-from-files”吗? - Can I use "--allow-file-access-from-files" when starting chrome app? get_file(fname, origin=_URL, extract=True) 不提取文件 - get_file(fname, origin=_URL, extract=True) not extracting the file javascript从具有不同来源的不同服务器下载音频/ mpeg内容 - javascript download audio/mpeg content from different server with different origin 如何获得原产地的“内容创建”? C#Winform - How to get “Content Created” of origin property? C# Winform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM