Options to store data on desktop, using webpage

 ̄綄美尐妖づ 提交于 2019-12-06 16:47:18

HTA (which is really just an html file with one extra tag and a different file extension) is one possible solution for windows users:

Important: Save as demo.hta to run on windows as an app

<!DOCTYPE html> 
<html> <!--   some parts lifted from  
  http://msdn.microsoft.com/en-us/library/ms536496(v=vs.85).aspx 
  http://msdn.microsoft.com/en-us/library/ms536473(v=vs.85).aspx
-->
<head>

  <title>State Saving Demo</title>

  <hta:application id="App" 
    application="yes"
    applicationname="demo" 
    icon="calc.exe"
    border="thin"
    caption="yes"
    sysmenu="yes"
    showintaskbar="yes"
    singleinstance="yes"
    sysmenu="no"
    maximizeButton="yes"
    minimizeButton="yes"
    navigable="no"
    scroll="yes"
    contextmenu="no"
    selection="no"  
    windowstate="normal" >  

     <!-- Use Internet Explorer 10 Standards mode (to use JSON, CSS3, etc...) -->
  <meta http-equiv="x-ua-compatible" content="IE=10">

</head>
<body onload=loadMe() >

<h1 id=h1>Command-line args: </h1>

<h3>Persisted Text</h3>
<textarea rows=20 cols=100 id=mydata onchange=saveMe() >
You can change me and i won't forget!
</textarea>

<script>
document.title+=" - Today is " + Date(); // task/title bar demo
h1.innerHTML+= JSON.stringify( App.commandLine ); // optional invocation info here (much like a real app)

// app-specific custom code:
FILENAME="state.txt";
function saveMe(){save(FILENAME, mydata.value); }
function loadMe(){mydata.value=load(FILENAME) || mydata.value;}

// generic utils: 
function load(filename) {   //IE FSO file Loader
          var file,
              text="", 
              fso= new ActiveXObject('Scripting.FileSystemObject');
          try{
            file = fso.OpenTextFile(filename, 1, false);
            text = file.readAll();
            file.Close();
          }catch(y){}
    return text;
} 

function save(filename, sData){   //IE FSO file Saver
          var file,
          fso = new ActiveXObject('Scripting.FileSystemObject');
          file = fso.CreateTextFile(filename, 2, false);
          file.write(sData);
          file.Close();
    return file;    
}     

</script>
</body>
</html>

I recently re-discovered HTAs, and they are not half bad. I don't think I would want to distribute and maintain them, but HTA's are an easy way to make simple desktop app using HTML, CSS, and JS. Its nice not to have to build anything to "recompile" the app after changes are made. saves a few steps compared to node-webkit, packaged apps, air, cordova, etc, but HTA's have a major downside: they only work on windows afaik...

Looks to me like you can use LocalStorage, the big question is how are you trying to store it? You can easily store an object/array into LocalStorage, and that object/array can be your data, then JS can output this into a table. If you're looking to store actual files then you're looking at something more like an ActiveX plugin.

http://caniuse.com/#search=localstorage

Alternatively if you have internet access through a desktop or a phone you can put this on Google Drive. This would be far easier than reinventing the wheel.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!