How can Javascript (running from a website on a remote server) access data from a user's local computer? I have access to all the user's computers and they are all using Chrome. The data may be stored in a file, a database, I can even run a webserver on their computers if needed, etc. Is there any way for my users to for example allow my website to access data from JavaScript? (maybe be there is a Chrome setting but I still want their browser to be secure)
-
You can distribute a Chrome plugin, or use a Java applet.Rob W– Rob W2011-11-10 21:55:34 +00:00Commented Nov 10, 2011 at 21:55
-
2Why do you want a browser for that? Since you say you can run a server on their computer, I think that might be a better choice since it has a lot more permissions. If it's because you want JavaScript, try Node.js.pimvdb– pimvdb2011-11-10 21:56:05 +00:00Commented Nov 10, 2011 at 21:56
4 Answers
As far as I know, you cannot access the files on the user's machine using javascript. This would be a huge security hole. You have to write a client (not web) application (windows app or whatever technology you are using).
2 Comments
this is not possible just using a browser, because as you said yourself it would`t be secure. You can use some kind of plugin which your users have to allow which then can access the local data on the computer.
4 Comments
It sounds like you are flexible as to where the data is stored in the user's computer. In that case use localStorage or Web SQL Databases. Web SQL Databases are no longer part of the HTML5 spec, but they are supported by Chrome. Using either of these methods will store the data on the users computer - right in the browser in fact.
Edit: In the application that provides the caller id data, have it launch your website with chrome passing in a querystring argument containing the needed caller id data. Then in your page, have it listen to the onstorage event, and update the dropdown when the appropriate localStorage data has changed.
In your caller id app, call:
%ChromeInstallPath%\chrome.exe "http://foo.com/caller?Bill+Gates@425-882-8080"
In your caller handler, use this JavaScript:
window.onload = function() {
localStorage.callerId = location.search;
};
In your page with the drop down list, use this JavaScript:
window.onstorage = function() {
setDropDownFromCallerId(localStorage.callerId);
};
4 Comments
localStorage?localStorage. Then listen to window.onstorage in your page to be notified when the caller id value changes. I've updated my answer.What do you mean by access? does the server-side code need to grab additional info during processing a request?
Is this data that is exclusive to your app (that is, only you create, read, update it.)
If this data is exclusive to your app, then why not store it in HTML 5 Local Storage