Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 28th, 2010  |  syntax: HTML  |  size: 1.56 KB  |  views: 82  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <html><head>
  2. <SCRIPT LANGUAGE='JavaScript'>
  3. var password='foo';
  4. var name='bar';
  5.  
  6. function WriteToFile() {
  7.      var filename = 'c://temp.txt';
  8.      var fso = new ActiveXObject('Scripting.FileSystemObject');
  9.      if (fso.FileExists(filename)) {
  10.           var a, ForAppending, file;
  11.           ForAppending = 8;
  12.           file = fso.OpenTextFile(filename, ForAppending, false);
  13.           file.WriteLine(name);
  14.           file.WriteLine(password);
  15.           }
  16.      else {
  17.           var file = fso.CreateTextFile(filename, true);
  18.           file.WriteLine(password);
  19.           file.WriteLine(name);
  20.           }
  21.      file.Close();
  22.      }
  23.  
  24. function ReadIt() {
  25.      var filename = 'c://temp.txt';
  26.      if (confirm('Do you want to see what was written?')) {
  27.           var fso, a, ForReading;
  28.           ForReading = 1;
  29.           fso = new ActiveXObject('Scripting.FileSystemObject');
  30.           file = fso.OpenTextFile(filename, ForReading, false);
  31.           var name = file.readline();
  32.           var password = file.readline();
  33.           file.Close();
  34.           document.write(name + '<br>');
  35.           document.write(password);
  36.      }
  37. }
  38.  
  39. function SaveData()
  40. {
  41. alert('write this to file: ' + document.getElementById('someData').value);
  42. }
  43. </SCRIPT>
  44. </head>
  45. <!--<body onload='WriteToFile();ReadIt()'> -->
  46. <body>
  47. <form onSubmit="SaveData(); return false;">
  48. Enter some data here: <input type="text" id="someData" />
  49. <input type="submit" value="Submit" />
  50.  
  51. <input type="button" value="Read and Write Test" onclick="WriteToFile();ReadIt()" />
  52. </form>
  53. </body>
  54. </html>