12

I'd like to write an application that would use both Javascript and HTML as for the user interface. The app wouldn't really need an internet connection but will need access to the user's local files.

My first thought was that this would be impossible in a browser due to the security restrictions on the access to local files.

My second thought was to try to use webkit directly from C++ and use Python instead of Javascript, but that seems rather complicated, and I feel like overkilling by using Qt.

My third thought was to use a signed Java applet to make all local accesses, but then I'm not too sure of this either.

Any suggestions on what I should do?

Manux
  • 3,323
  • 3
  • 26
  • 40

7 Answers7

6

I'll admit that I know very little about this, but it sounds like what you're after is what XUL provides.

From the homepage:

XUL (XML User Interface Language) is Mozilla's XML-based language that lets you build feature-rich cross platform applications that can run connected or disconnected from the Internet.

...

Web developers already familiar with Dynamic HTML (DHTML) will learn XUL quickly and can start building applications right away.

Regarding filesystem access: https://developer.mozilla.org/en/Code_snippets/File_I//O

This article describes local file input/output in chrome JavaScript.

You access the file system using Mozilla XPCOM components. A list of resources and interfaces for local I/O is available for both Files and Streams at XUL Planet.

Because of my lack of familiarity, I'll leave it up to the community to decide whether or not this answer has merit.

EDIT: Making this answer a community wiki since I don't have much real information to offer.

Community
  • 1
  • 1
user113716
  • 299,514
  • 60
  • 431
  • 433
  • 1
    This looks quite interesting, I'll take a look. – Manux Jan 28 '11 at 21:47
  • 1
    Haven't tried this myself yet, but providing a XUL application with a browser view (like [XUL Webapp Wrapper](https://github.com/neam/webapp-xul-wrapper)) is a good start, then you can probably use [XUL's message manager](https://developer.mozilla.org/en-US/docs/The_message_manager) to set-up communication between the Javascript and the XUL application (in where XPCOM components can be accessed) – Motin Mar 08 '13 at 17:16
3

It seems, 5 years after the question was asked, there is a framework to do exactly this: build cross platform desktop app with JavaScript, HTML, and CSS, and with access to local files, http://electron.atom.io/.

I have not used it myself, but it is recommended in other answers.

Community
  • 1
  • 1
Alex Fainshtein
  • 1,013
  • 8
  • 17
1

You can always install needed servers locally and access user's local files that way.

I have been using Server2Go and MAMP

hade
  • 1,685
  • 1
  • 15
  • 23
1

You could - for example - use Cappuccino: It allows you to build Applications in Objective-J (a language written in JavaScript) and run them either in the browser or as a Desktop application with local file access .

Then there is Adobe AIR, which allows you to write apps in JavaScript/HTML and access the file system.

Or you could use the new File Access API: http://hacks.mozilla.org/2009/12/w3c-fileapi-in-firefox-3-6/ (it has big restrictions, though: HTML 5 File API)

JavaScript is a beautiful language! Please update this question with information on which route you choose.

Community
  • 1
  • 1
Johannes Fahrenkrug
  • 38,500
  • 17
  • 113
  • 155
  • I'll look at the first 2. The HTML5 File API can only access files selected by the user; in my current position this would be quite annoying to do because of the quantity of files. – Manux Jan 28 '11 at 21:48
  • I see. Cappuccino is a great framework and has a very active community. I'd definitely strongly suggest that route over Adobe AIR. – Johannes Fahrenkrug Jan 28 '11 at 21:52
1

If you're not a Microsoft basher and/or don't mind being bound to IE, a Hypertext Terminal Application (HTA) is another option. I once (long ago) create a complete and pretty large stand alone database-application using HTA.

KooiInc
  • 104,388
  • 28
  • 131
  • 164
0

Do you know PHP? I suggest you to install Wamp or phpTriad or something similar for Windows. That way you can reach to the local files. If it is Linux most of the *nix based operating systems have build in Apache and PHP..

borayeris
  • 2,353
  • 1
  • 24
  • 31
0

Mozilla currently develops Chromeless, which seems to be able to do exactly what you want and has filesystem access

flying sheep
  • 7,563
  • 4
  • 49
  • 68
  • Unfortunately, Chromeless project is considered inactive and have no commits for more then 2 years. – Meglio Mar 02 '13 at 14:03