Question

I'm using jQuery .load() to load some pages in a div. I'm testing a mobile web site with Chrome's mobile web site emulator.

Apart this, the thing is that I get this error:

XMLHttpRequest cannot load .../www/pages/welcome_header.html. Received an invalid response. Origin 'null' is therefore not allowed access.

Indeed this i a problem CHrome only has.

It looks that a solution is to use

--allow-file-access-from-files when starting Chrome.

But how do I do it on Windows 8?

I tried with

"run" ==> "chrome --allow-file-access-from-files".

But had not effect

Thanks in advance for any clue.

Was it helpful?

Solution

update: proof that it works on my Windows 8 machine, and some troubleshooting steps for you:

enter image description here

  1. Local file
  2. Warning about Chrome flag
  3. These are text files loaded via RequireJS (which uses XMLHttpRequest)

Detailed steps/troubleshooting:

  1. Log in as an Administrator to ensure security restrictions are not preventing anything.
  2. Make sure all instances of Chrome are closed.
  3. Make sure Chrome is running in "Desktop" mode. In Windows 8, Chrome can run in "Windows 8" Metro mode, which has more strict security restrictions.
  4. Run the following command (from "run" menu, cmd.exe, or batch file):

    chrome --disable-web-security --allow-file-access-from-files
    

update 2:

The error message you are getting is different from what I get when I omit --allow-file-access-from-files:

XMLHttpRequest cannot load file:///C:/Users/.../main.coffee. Cross origin requests are only supported for HTTP.

  1. Use the latest version of Chrome.
  2. Check how you are using XMLHttpRequest. Check the browser debugger's network tab. Perhaps Chrome interprets your file URL differently than other browsers?

(...and I guess --disable-web-security is not required.)


Chrome must be passed --allow-file-access-from-files when it first starts. Make sure all instances of Chrome are closed, first (otherwise the instance without the parameter is re-used). I would also add --disable-web-security for good measure. Chrome should display a yellow notification banner warning about unsupported and unsecure settings.

I've been doing this to locally test a hybrid app for iPad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top