Im have been working on a project with the createjs library and I have used Brackets with Live preview where everything works perfectly, but if I just open the file in a browser I get the following error message in chrome.
XMLHttpRequest cannot load file:///C:/Users/Maskinen/Docuemnts/fail.fail. Cross origin requests are only supported for HTTP.
I have read that if I set loadqueue(false) I wouldnt get problems with loading local files. I therefore thought that when it was working in live preview in brackets everything was fine. Is it possible to run chrome or firefox as Brackets in live preview or similar? The project is part of an assignment and it isnt possible to use a webserver :(
This it what is found by searching around for a bit:
If you launch chrome.exe like this it should work
chrome.exe --args --disable-web-security
When you're done restart chrome without the args and it works like normal again.
Source:
http://robandlauren.com/2013/09/25/cross-origin-ajax-requests-localhost-chrome/
I prefer to be more specific to it and use allow-file-access-from-files flag.
To do that execute chrome with this option:
Windows
cmd
chrome --allow-file-access-from-files
Mac
bash
open /Applications/Google\ Chrome.app --args --allow-file-access-from-files
Even thought this is disabling security protections so be careful with it, and enable it back to browse securely 😀
Related
I'm trying to grab data from one website and use it to write something into another website (using JQuery/Javascript). Understandably, the same origin rules weren't going to let that happen, but I figured disabling web security/CORS on my browser should fix that problem. For some reason, I can't get the policy disabled in Chrome, and I can't figure out why.
I've tried launching Chrome with --disable-web-security --user-data-dir=
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="C:\Users\<username>\Desktop\chromeTemp"
I expected to be able to open a new tab, access 'document' in the console, and find a link I want to 'click', but instead I got
VM186:1 Uncaught DOMException: Blocked a frame with origin <url> from accessing a cross-origin frame.
I thought this would no longer be blocked?
Looks like there might be an open bug for this, possibly try an older chrome version.
https://bugs.chromium.org/p/chromium/issues/detail?id=840124
See Last Comment on workaround:
"The workaround is to download an old version of Chrome as a portable app : https://sourceforge.net/projects/portableapps/files/Google%20Chrome%20Portable/ (version 66.0.3359.181 still works). It's the one I use when I'm developing..."
The Chrome command switch allow-file-access-from-files allows local scripts to access other local script files (necessary for testing javascript Workers locally https://stackoverflow.com/a/35117877/209942).
That works for me.
Incognito runs a sandboxed Chrome. Also works.
Problem: the switches do not seem to be compatible. If i run
chrome.exe --allow-file-access-from-files --incognito
the allow-file-access-from-files flag does not take effect.
Any way to combine these flags? That would conveniently enable me to run a secure and non-secure instance of Chrome at the same time.
thx
Update:
FYI, i may have uncovered a Chrome security bug:
allow-file-access-from-files works as expected in an incognito window if incognito is launched from the menu of a chrome running with the allow-file-access-from-files flag.
But if a normal chrome instance is running (without the allow-file-access-from-files flag), and then you execute chrome.exe --allow-file-access-from-files --incognito from a command-line, allow-file-access-from-files fails in the incognito instance.
It's contradictory for these features to work together when incognito is opened from the UI, but NOT work together when incognito is launched via command-line switch.
(I reported the above as a bug to Chromium bug reporter. https://code.google.com/p/chromium/issues/detail?id=582986
The report might not be public yet ).
My goal is to run two Chrome windows, one without allow-file-access-from-files, the other with allow-file-access-from-files. This is for development convenience.
Aside from incognito, I also tried using different profiles to achieve my goal-- doesn't work. Both profiles behave the same regarding allow-file-access-from-files-- the first profile launched will determine allow-file-access-from-files state for any subsequent profiles launched, regardless of startup flags.
I finally achieved my goal with the user-data-dir flag, to enable allow-file-access-from-files in one chrome instance, and not to another instance. (incognito and profiles are unnecessary).
It's used this way:
chrome.exe --user-data-dir=D:\MySeparateChromeFolder
Before using this flag, create the D:\MySeparateChromeFolder (change the name and location to whatever you want), but don't put anything in it. Then run the above command (with your desired name and location) from a command-window, the Run box, or make a new shortcut containing this command.
This will launch a completely independent Chrome -- more extreme than profiles. Chrome launched with this flag will have almost nothing in common with Chrome launched without this flag. It will have separate extensions, history, settings, bookmarks, etc, and, most important to this thread, other startup flags used with this instance (such as allow-file-access-from-files) will be independent of other running chrome instances.
I have one extension for firefox done, no erros on the code, everything is working, but for some reason sometimes stop working and make firefox crash. I made a lot of testes and different cases.
My question is, how can I debug this extension?
There's some way quicker to install the extension then everytime I make some change I need to compress to zip, uninstall and reinstall again the extension.
I'm using Firefox 25.0 on Ubuntu 13.10
You can Open about:crashes page in Firefox there will be a lot of info about your Firefox crashes(if it really crashes). If this is just JavaScript errors, try using Firebug or JavaScript console to get more info
I'm in the process of creating an Android test farm system, and while at it, I'm trying to find a way to inject javascript in an already open tab in the default browser.
I'm trying with
adb shell am start -a android.intent.action.VIEW -d "javascript:alert('Hello world!');" -n com.android.browser/com.android.browser.BrowserActivity
and while it works, it opens in a new tab.
Is there any way to do it in the current tab?
If you're cool with using Chrome, which is the default browser for newer versions of Android, you can use Chrome's remote debugging.
Once you've enabled this on the device (enable usb debugging + web debugging), you can connect by executing:
adb forward tcp:9222 localabstract:chrome_devtools_remote
If you hit localhost:9222 from your browser, you'll see the chrome dev tools for each one of your tabs. From here, you can do anything you could usually do in the desktop chrome inspector, including executing JavaScript from the console.
If this is not automated enough, you can write an app that uses a WebView, configure it to handle an intent where you provide arbitrary JavaScript, and use webview.loadUrl(js) to execute it.
I want to bring a web application from PhoneGap to pc browser just because I need to do some tests. Inside the WebApp there are some XMLHttpRequest which fail because the Header origin is null.
I've already tried to run Chrome with this command :
chromium-browser index.html --allow-file-access-from-files
I've got the same error :
Origin file:// is not allowed by Access-Control-Allow-Origin.
I can't understand why with android emulator everything works properly.
Also phonegap loads the local file :
super.loadUrl("file:///android_asset/www/index.html", 1);
More or less I've solved it with this add On for Firefox!
It might be useful for others people :
Firefox add-ons Force CORS
Try using this flag --disable-web-security when launching chromium. Obviously, it's for dev purposes only.