For school we have to make a site.
That site has to run from a local file by opening the index.html.
I am using:
<script type="text/javascript">
$("#navbar").load("SideBar.html");
</script>
To get a sidebar.
The problem is that I get the XMLHTTPREQUEST error on Chrome, on safari it works perfectly.
The teacher does not allow to use a webserver.
What can I do so that my teacher is able to run my site without a webserver?
This is due to chrome security policies. If you don't disable it you won't be able to load local file.
You can disable it by running chrome with the following command on windows.
chrome.exe --allow-file-access-from-files
There's a bit more information here.
Related
I'm trying to write an app using Sencha Touch that ultimately targets iOS and Android. It's supposed to log into the corporate web server and then retrieve and parse some JSON data. It should be very simple. However I'm very new to both Sencha and Javascript, so I'm having a hard time doing this sort of client-side authentication. I can't even seem to make it authenticate from a web browser on my dev machine.
I used this link to help create my login page:
http://miamicoder.com/2012/adding-a-login-screen-to-a-sencha-touch-application/
But when I attempt to log in I seem to get the following error message and a null object:
XMLHttpRequest cannot load https://www.server.com/index.html?=_dc1234567890123
Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin.
Does anyone have any advice or good resources on getting this app to log in? Any help would be greatly appreciated!
Steve, the "is not allowed" error is returned because your login request violates the browser's same-origin policy (essentially it states that all XhrHttpRequests must go to the same domain the page was initially loaded from).
Some browsers offer ways of disabling this error temporarily (which might be fine for short-term development purposes), but for the long-term you'll either need to host your application in the same domain as your backend server, or look into using CORS or JSONP for your requests.
Your AJAX request violates the Same-Origin-Policy. That's why you are getting the error message. If you are using chrome for debugging u can disable the cross-domain Javascript security by doing the following :
For Windows:
1) Create a shortcut to Chrome on your desktop. Right-click on the shortcut and choose Properties, then switch to “Shortcut” tab.
2) In the “Target” field, append the following: –args –disable-web-security
For Mac, Open a terminal window and run this from command-line:
open ~/Applications/Google\ Chrome.app/ –args –disable-web-security
For Ubuntu, Open a terminal window and run this form command line:
open /usr/bin/ and execute ./google-chrome --disable-web-security
There is extension for chrome that does the work:
Allow-Control-Allow-Origin.
If you want to active it when the browser started, you have to press on the icon.
I have just started making Facebook Apps using heroku. I made a test app. I uploaded a page on heroku which uses HTML5, CSS and Javascript. The app is not showing in Google Chrome https://apps.facebook.com/shrytestapp/ but works well in Mozilla Firefox. Also, the page works well when opened in heroku server http://salty-shelf-6707.herokuapp.com/.
When you access the app within Facebook, HTTPS is used to transfer the data, but Chrome has blocked content delivered over normal HTTP as a result and insists that everything be transfered securely whereas Firefox isn't so fussy.
Here's what the Console is showing in Chrome
[blocked] The page at https://salty-shelf-6707.herokuapp.com/
ran insecure content from http://www.google.com/jsapi.
Uncaught ReferenceError: google is not defined
Google's JS API has been blocked and the JavaScript fails to run.
(You also have some not found errors, but that's unrelated)
The app works fine through the http://salty-shelf-6707.herokuapp.com/ as you mentioned, but not through https://salty-shelf-6707.herokuapp.com/
Try using the following instead to load the API
<script type="text/javascript" src="//www.google.com/jsapi"></script>
the // at the start of the src value will make the url protocol-relative or for the correct technical term, scheme-relative.
Paul Irish, the lead developer of HTML5 Boilerplate, has more information about this in a post on his site.
In firefox InstallTrigger.install is used to download xpi file. What is used to download the crx file in chrome browser. The download should start without the user click.
Simply change the location of your window, use window.location.href = "http://.../extension.crx";.
Edit: The answer above is outdated, Chrome no longer requires installing extensions from any website other than Chrome WebStore.
There is a supported inline installation flow that allows you to trigger installation for your extension from your website. This requires your website to be verified and associated with the extension in the Chrome Web Store. Then you can add a <link rel="chrome-webstore-item"> tag to the page pointing to your extension in Chrome Web Store and a call to chrome.webstore.install() will start installation.
I am using jquery and running a html file on my local machine (no server).
The following works on firefox but not on chrome:
$('#result').load('test.html');
It seem to be something wrong with the path.
Anyone know how to sort this out without having to add an absolute path please?
Thanks
Ajax requests cannot be sent cross-domain. On your local machine, every request is cross-domain to the browser, so no Ajax can be used at all. Chrome is a bit more strict than Firefox here. There is no solution, you will just have to upload it to a web server or install something like Apache on your local machine for testing purposes.
Typically, AJAX requests cannot be sent cross-domain, however, if you're just looking to access a local file, you could try enabling one of Chrome's secret flags. Specifically:
--allow-file-access-from-files
With any luck, you should be able to get things working by changing your chrome shortcut to the following:
chrome.exe --allow-file-access-from-files
I'm not sure if that flag is enabled in all builds of Chrome (I am presently running chromium 10), but it definitely works: I've been using it to enable file-save access in TiddlyWiki.
I wrote a very simple extension for Safari 5 that only outputs a single log message from a start script. This is the start script:
console.log('start script running');
If I go to any internet page (eg. http://www.yahoo.com) the log message appears in the error console. But if I open any local html page no log message appears. By local I mean on my local machine. It's like my start script never gets run for local pages (eg. C:/blank.html).
Is there a permission setting I'm overlooking or is this a feature of Safari 5?
Brent
Caveat: I only have a passing familiarity with the Safari extension system. I work on Google Chrome which is based on Webkit. Safari is also based on webkit.
In a Google Chrome extension, you can inject a script into a local page using the file:// permission. But I’m pretty sure there’s no analogue for Safari extensions.
The Safari page on script injection also seems to say you can’t interact with local files:
“You cannot access resources on the user’s hard drive outside of the extensions folder.”
There is no way to inject scripts on local files.
If you feel like it, you may complain at bugreport.apple.com.