Opening downloaded Gist folder to inspect elements - google-chrome

I want to experiment with Mike Bostock's stacked bar chart (https://gist.github.com/3886208) in my browser using web inspector. I realize that I need a local copy of the example files (the index.html and the data.csv file) in order to play with it. However, when I download the 'gist' folder and open the index.html file with Chrome, the chart doesn't appear. What am I doing wrong?
Thanks!

With Google Chrome, go to Top Menu > View > Developer > Javascript console. You will see a message
XMLHttpRequest cannot load file:///path/to/data.csv. Cross origin requests are only supported for HTTP.
As per https://github.com/mbostock/d3/wiki
When developing locally, note that your browser may enforce strict
permissions for reading files out of the local file system. If you use
d3.xhr locally (including d3.json et al.), you must have a local web
server. For example, you can run Python's built-in server:
python -m SimpleHTTPServer 8888 &
Once this is running, go to http://localhost:8888/.

Related

Mediawiki: Links to open local files on the server doesn't work

I have MediaWiki installed on a synology server. I would like to create a link on the wiki that would allow opening of files on the same server.
Here are the steps I did to achieve this:
Added $wgUrlProtocols[] = "file://"; in LocalSettings.php
A test file on the server: file://myServerName/path/to/file/test.txt. Putting this URL in my chrome browser directly opens the file.
Create a page in MediaWiki with a link to this file using [[file://myServerName/path/to/file/test.txt]]
When I click on the generated wiki page, nothing happens. However when I hover on top of the link, it shows the correct URL.
Can someone please point out what additional steps I need to do to get this working?
The file:// protocol points to the file on your computer. I'm not fully sure, but I think you cannot use it to retrieve file from a different machine (read my comment below about samba shares).
From quick research it looks like Chrome browser blocks requests with file:// protocol, But browsers like IE should allow you to open those files. It is done because of security reasons so the malicious site cannot open local files without your permission. You might bypass that by installing a special plugin in Chrome (look for Enable file links)
Instead of using file protocol, make those files available via Synology WebStation, and then create links that point to the file via webstation (not via path on the server). With that approach, links attached on your MediaWiki pages will work as those will be regular links.
If you don't use the WebStation, you might also try with ftp:// links (use the FTP service), or link to samba shares - that's where the file:// protocol might work, but again - I'm not sure and I cannot test it as I do not use windows.
I think that the safest/easiest/fastest way is to expose those files via WebStation.
Source: https://en.wikipedia.org/wiki/File_URI_scheme
The file URI scheme is a URI scheme defined in RFC 8089, typically used to retrieve files from within one's own computer.

Is transcrypt supposed to run from the local filesystem?

I've installed Transcrypt, compiled the Hello Solar System demo, and run it as instructed using the python web server.
However, I was also able to run the hello.html file directly from Chrome on Windows 10 ... once. Subsequently it refuses to run - the buttons appear but clicking them does not update the text.
------- EDIT ---------
Thanks - CORS is the problem - the browser must connect to a web server, not a file on the local filesystem.
You've probably run into a security policy of Chrome called CORS. Start a webserver from the directory where your html file is, using python -m http.server, and browse to localhost:8000. In your browser window, click on the html file and things should work.

How to allow-file-access-from-files in Chrome?

I am using Chrome to test some of my WebGL texture programs. According to the book 'WebGL Programming Guide', if I need to access files from my local disk, I should add the option --allow-file-access-from-files to Chrome.
How do I do that?
The short answer is DON'T
Open up a shell/terminal/command line and type
cd path/to/htmlfiles
python -m SimpleHTTPServer
Then in your browser to go
http://localhost:8000
If you find it's too slow consider this solution
The reason you don't want to allow file access is allowing it can be used to steal data from your machine. For example, you go to a site and download some webpage. You then view that page locally. With file access on that locally run page can now access all your files AND upload them to a server.

WebGL Inspector Extension Does Not Appear in Chrome for file:// urls?

My steps (these are the ones described in the docs), under Win 7:
Downloaded/unpacked the zip file
using cygwin, ran the buildextensions.sh file, which created the lib and extensions dirs
opened Chrome
installed the webgl extension via the chrome store
(various repeats of closing/relaunched chrome along the way from here on, with little help)
chrome setup->extnesions, make sure webgl is enabled
turn on developer mode, "load unpacked extension...." selecting the (created) extensions/chrome directory (in this case, C:\Users\kbjorke\Documents\benvanik-WebGL-Inspector-6108bee\benvanik-WebGL-Inspector-6108bee\core\extensions ) and allow "file://" url's
??? no amount of relaod/update/restart seems to cause the GL logo to appear among the extensions buttons at upper right -- even when I load webgl-intensive pages, UNLESS I first load a webgl page from some NON-file:// page -- if I open another tab with an http:// webgl page, I see the red "GL" indicator TWICE in that address bar, but they both lead to the http:// page, not my file:// !
How can I get at my own page, short of pushing it to an external server?
Use a local server. Just open a command prompt, cd to your webpages and then type
python -m SimpleHTTPServer
Then go to
http://localhost:8000
I don't think extensions are allowed to run on file:: urls because then an extension could read your hard drive.
If you are doing video or audio then try this node server.
I just downloaded WebGL Inspector 1.13, and it has a setting (under Settings>Extensions>WebGL Inspector) that reads "Allow access to file URLs". Does what it sounds like - all set!

HTML 5 GeoLocation in Google Chrome

I am using HTML 5 Geolocations API's for tracking location however I am getting the following error on the Geolocation icon in Chrome Browser
"This Page has been blocked from tracking your Location"
I went to the Preferences and Setting's Page but did not find any help.
In my case the problem was that I opened the HTML file from the file system (file:///...). Browsers generally try to prevent accessing personal information (which includes location) from local files, so you have to serve the file through a web server (even if it is local).
One simple way to serve a static website located in your filesystem is SimpleHTTPServer if you have Python installed. Just navigate to the folder using the command prompt, and say python -m SimpleHTTPServer, and then you can view the file on localhost:8000.
Even I was facing the same problem. One of the solution is to open to file in another browser, I tried in Firefox and it worked fine. Another solution is to open the file through your WAMP server (Local host).
There is a good article here about Geolocation API. You have to go to chrome://settings/content and there, you can find Location information. You should be able to find the exceptions and manage them there.