简体   繁体   中英

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. The HTML pages use jQuery and knockout.js and load data from the JSON file using $.getJSON .

This runs fine on Firefox but I get an origin null is not allowed by access-control-allow-origin on Chrome. 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.

Is there a way to let Chrome open local files?

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.

My solution was to use a javascript loader (ex: HeadJS) which does a great job for an application needing to run offline. I would create a file with .js in this manner.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM