I'm developing an offline "application", based on HTML5. For my purpose I need to read a local json file but, as I experienced and as I read, through javascript this option is unavailable because of security policies.
Have you any idea about how to bypass the problem? Every hint is well accepted.
That's not entirely true.
Chrome has some security restrictions that prevent local JSON being read by default; however Firefox for example works fine out of the box.
There are some workarounds for Chrome, however the fixes usually rely on modifying settings on the clients machine.
If you want to create an "offline application" than why do you want to use webtools like a browser (and not JavaFX, Windows, ...).
You can say that you want to use the browser as a client for your purposes (or you are webdeveloper). Then you can use a local server to serve you "offline". Simple to start most of them not even to install or needed a large environment.
There are a plenty of local server and they are very powerfull to do anything you want. Search the web for web servers, languages or frameworks like: play framework, nodejs and many many more.
After using such a server you can access any local service or local files.
This is how webdevelopers work on their local machines and transfering that to the target server afterwards.
Related
I do not want to allow Web Debuggers such as Charles Proxy, Fiddler, Wireshark, etc while using my Node JS application. I'm not fully sure what's the best way to do this. Is there a way to detect when a new program is launched in node, and then check if it's a web debugger?
I just don't want people intercepting requests sent from the node app.
I have tried getting all running processes on user's computer, and if any are a web debuggers, close my app, but this requires checking the running processes every couple seconds.
There is no effective way for you to do this. There are more debugging tools than you could imagine to check for, and there are ways that they could be hidden beyond your ability to detect (like running them on another computer, or running your application inside a virtual machine). Besides, your application is written in an interpreted language -- any user savvy enough to use a debugging tool could just as easily open up your application and remove the code that was supposed to disable their tools.
You haven't gone into much detail about why you're trying to do this, but the fact that you're asking is a sign that your application may be structured incorrectly. If your application is communicating with a server, any access controls (e.g. on what information the client has access to, or on what operations it can perform) should be implemented on the server -- the fact that the client can "see" what is going to and from the server should not compromise the security of your system.
That is impossible! Browser is a software, just like Charles Proxy, Fiddler, Wireshark, etc ...
In our web application, we using a Java applet to invoke MS.Word application by jacob jar e.g. Word to open, edit, and when it saves automatically it uploaded to the server.
Google Chrome will no longer support NPAPI, so soon we can not run our applet in Chrome anymore.
So, any suggestions for an alternative for the Java applet. We want to make the same experience for the user, just like before.
We have the same problem. With Webstart is not longer possible to do that communication. We are going to use Websockets between webstart application and browser. Our first attempt is to start a websockets server in the webstart and make browser connect to localhosts. If this is not possible for security limitations in the browsers then we are going to do it through the webserver, browser and webstart application connecting to the webserver and exchanging messages.
I can see 2 distinct possibilities.
Create a standalone application that "wraps" your web application using a technology such as electron. You can then do your browser to desktop integration as you like. This will require an install on the client.
Launch a webstart application (or it could really be any installation that happens on the client). It will need to start a webserver, or connect to a webserver and communicate via http.
I'm saddened by the loss of the Applet. It is a technology not easily replaced. And another methods seem somewhat like 'workarounds'. There is no easy, cross-browser way to break out of the browser sandbox and access the system.
For myself, the loss of the Applet has simply meant that automating some of these processes has become too difficult and it is just better to find an alternative way of achieving a similar end result.
A small note: If you are starting a local webserver, be mindful of security. It can be accessed by other processes on the system. Wouldn't it be fun to open word on anyone's system by sending a request to a port!
I want to be able to create an offline program that can use the browser as GUI. I'm not particularly good at GUI programming in general, and overall it seems that using HTML and CSS to structure a GUI would be the easiest.
Cross browser method is preferred, but I will most likely use Google Chrome
I need to be able to open an external program, possibly with command line arguments
Javascript seems like the best language for this, however as far as I know it isn't possible to launch programs with it.
This is on Windows 7.
That's a good idea and is done by a several popular softwares.
The best way is to make your offline program run a web server that the browser will be able to access.
ie: Your program starts a web server on localhost:5555 and then you'll be able to request http://localhost:5555/users in Javascript, from your browser.
Another approach could be using a UI framework like AngularJS + local storage. I'm working on an app right now that will be used online (connected to the web), online locally (connected to a local server that is not connected to the web), and offline.
You could build a single-page web app and let Angular manage all the "urls".
We have a legacy software package made for native Windows. I'm writing a system to automate installing updates. One of the options is for the client to visit a web page, and from that web page, check for updates to their installation. There are two ways of identifying the software version: either reading a particular EXE file and looking at its file version, or reading the registry for our software (actually the third way is reading from their SQL Server database but that's obviously out of the question). Either of these methods would work, but I have no idea how to do it from javascript in a browser.
I'm sure there is some security, but I have seen other systems do this, so I'm sure it's possible. In general, the web page can check the client's computer for existence of certain software, and if it exists, check for the version. How can I do this from Javascript?
In MaVRoSCy's comment above: "only in IE this is possible with some ActiveX help, except if you run a dedicated local server just to serve this functionality". This actually fits perfectly, because each client computer already has a Windows Service running in the background at all times.
A simple HTTP server can be added into this client service listening on a universal non-common port number such as 16580. This HTTP server can handle requests like /currentversion which returns the current application version.
The javascript on the web page (hosted elsewhere but viewed on that client's browser) calls http://127.0.0.1:16580/currentversion to obtain the latest version.
One of the options is for the client to visit a web page, and from that web page, check for updates to their installation
Bad idea and wrong methodology
Checker|Updater have to be embedded into app
Checker have to (on start|on demand|whatever)
identify build of local app (any usable way)
Get && parse external permanent URL with data of Latest Existing Build (at least version and URL of Build)
Inform, if needed, about new version and|or download|update core, if requested by user|configuration
I need a database storage system for Javascript where the state can be maintained on the local disk.
Here comes the spanners in the works :-
It only needs to support Internet Explorer but the minimum version must be IE6
Files need to be written so they can be read in again later (upon closing and re-opening of browser)
There can be no web server (unless it's extremely easy to distribute and does not require a install) since the HTML pages will be distributed on USB.
Does anyone know of any solutions that might help here?
Have fun playing with userData. Apparently it does what you want in IE6/7
Then localStorage for IE8/9
Or you can use the heavier store.js which does the feature detection for you and apparently works in IE6+.
It should work in IE9 but no garantuees. I would recommend store.js as it's easier for maintenance and just works out of the box. You can also support other browsers that way.
I don't know if it's supported in IE6, but JScript appears to have some level of support for this through FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
According to Write binary data with FileSystemObject write(), ADODB.Stream appears to be an alternative.
For strictly local IE work use HTA Applications. Then you can access local resources (text files, ADO databases) without security problems.
try to read this post: Read/write to file using jQuery
Hope this helps.
I would suggest that you not try to read/write using JavaScript but instead head down the road of embedding a small web server on the USB drive. I did this for an app once and it worked out well. I used the Cassini web server.
I created two projects in visual studio. First, I created an ASP.Net web site to read/write from an SQLite database. This site displayed all my content and was built just like any other ASP.Net site. Second, I created a Windows Forms application that hosted the Cassini web server and presented the user with a form that contained a single web browser control. This made the user experience very simple ... they just clicked MYAPP.EXE from the root of the USB drive and the form opens, starts the web server, and navigates the browser control to the start page of the web site.