View difference between Paste ID: zruxy51V and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
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> |