问题
I have been developing an AJAX application using jQuery and Microsoft Seadragon technology.
I need to have access to the html5 canvas function toDataURL.
With Google Chrome, the same origin rule applies to this function which means that a page run locally (with the file:///
in the URL) failed to satisfy the same origin rule and an exception is thrown.
With Chrome 7, starting the application with --allow-file-access-from-files
option, allows to call canvas.toDataURL()
from local files.
However, it seems that starting the Chrome Beta 8 with the same option (--allow-file-access-from-files
) does not allow the call canvas.toDataURL()
on the local file.
Does Chrome gave up on the --allow-file-access-from-files
option or it has just been disabled since it is a Beta release and not a full release?
Thanks!
回答1:
Looking at the issues for this shows that the whole --allow-file-access-from-files
thing was rushed.
- "Firefox does it.."
- "How can we do it?"
- some time passes
- "Here are the patches"
- "Passes! On trunk wonder what happens in the next dev release"
- "Ahhh it's broken" "Use the command line option" "ok"
- "We shipped!"
- "WTF guys? You broke all my stuff! Why didn't you tell us earlier?"
- silence
On to your Problem
Indeed it seems that this is something special to the beta, I'm using Chrome 8.0.552.5 dev
here and --allow-file-access-from-files
works like expected, I've also tested this with Chromium 9.0.592.0 (66889)
were it also works as expected.
I suspect there have been some changes on the dev branch. Unfortunately, finding something on chromium's issue tracker is nearly impossible.
回答2:
Did you close all chrome instances before opening with the command line argument? You have to do that to make that parameter work.
回答3:
To summarize all answers so far.
Before running chrome, make sure there are no chrome processes running.
Windows
-allow-file-access-from-files
(with one dash)
Linux
--allow-file-access-from-files
(with two dashes)
回答4:
I've found a way around the issue using a JavaScript/Flash approach. If flash is compiled in the Local Only security sandbox, it has full access to local files. Using ExternalInterface, JavaScript can request a Flash Application to load a file, and Flash can pass the result back to JavaScript.
You can find my implementation here: https://code.google.com/p/flash-loader/
回答5:
The trick that woked for me is that you have to give the absolute path of the file and not just file name in your HTML code. e.g file://... instead of direct name even though you are accessing the file in the same directory. It will work!
来源:https://stackoverflow.com/questions/4270999/google-chrome-allow-file-access-from-files-disabled-for-chrome-beta-8