views:

1507

answers:

5

I was pretty sure the answer was NO, and hence google gears, adobe AIR, etc.

If I was right, then how does http://tiddlywiki.com work? It is persistent and written in javascript. It is also just a single HTML file that has no external (serverside) dependencies. WTF? Where/how does it store its state?

+16  A: 

Tiddlywiki has several methods of saving data, depending on which browser is used.

  • If ActiveX is enabled, it uses Scripting.FileSystemObject.
  • On Gecko-based browsers, it tries to use UniversalXPConnect.
  • If Java is enabled, it uses the TiddlySaver Java applet.
  • If Java LiveConnect is enabled, it tries to use Java's file classes.
Zr40
+5  A: 

It uses a java file references like this:

drivers.tiddlySaver = {
     name: "tiddlySaver",
     deferredInit: function() {
      if(!document.applets["TiddlySaver"] && !$.browser.mozilla && !$.browser.msie && document.location.toString().substr(0,5) == "file:") {
       $(document.body).append("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1'height='1'></applet>");
      }
     },
     isAvailable: function() {
      return !!document.applets["TiddlySaver"];
     },
     loadFile: function(filePath) {
      var r;
      try {
       if(document.applets["TiddlySaver"]) {
        r = document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8");
        return (r === undefined || r === null) ? null : String(r);
       }
      } catch(ex) {
      }
      return null;
     },
     saveFile: function(filePath,content) {
      try {
       if(document.applets["TiddlySaver"])
        return document.applets["TiddlySaver"].saveFile(javaUrlToFilename(filePath),"UTF-8",content);
      } catch(ex) {
      }
      return null;
     }
    }
Rich Bradshaw
+1  A: 

The answer is indeed NO. Java applets, and the dreaded ActiveX plugins are usually used if this is required

Sheff
+2  A: 

Technically you can do

netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');

in a netscape-compatible browser (Firefox, Mozilla, Netscape), and it will ask the user* whether or not to allow filesystem access, but this is not portable.

*once per browser process

Jason S
A: 

The answer is in the future, it will. See www.w3.org/TR/FileAPI/ With Firefox 3.6.8 see http://www.html5rocks.com/tutorials/file/dndfiles/ for samples with source code.

John