Autor | Zpráva | ||
---|---|---|---|
zacatecnik9 Profil |
#1 · Zasláno: 29. 3. 2009, 19:33:55
Nevíte prosím, jak vyexportovat text z textarea pomocí javascriptu do .txt souboru na lokálním počítači?
Dík |
||
Joker Profil |
#2 · Zasláno: 29. 3. 2009, 19:41:00
Nejde, Javascript nemůže vytvářet soubory, kromě cookies.
Teoreticky by to šlo přes Java applet nebo ActiveX. |
||
zacatecnik9 Profil |
#3 · Zasláno: 29. 3. 2009, 19:45:17
... nojo, ono by to asi nemuselo dopadnout dobře, kdyby si natahované stránky vytvářely na lokálních kompech soubory a psaly tam něco šíleného ...
|
||
Bubák Profil |
#4 · Zasláno: 29. 3. 2009, 20:30:24
http://diskuse.jakpsatweb.cz/index.php?action=vthread&topic=61193&forum=8&page=-1#3
Někde v této Diskusi se tohle probíralo podrobněji, ale nenašel jsem http://diskuse.jakpsatweb.cz/index.php?action=vthread&topic=61193&forum=8&page=-1#4 tatáž stránka, jiný postup, ale nefunguje v IE7 a starších |
||
zvěřiňák Profil * |
#5 · Zasláno: 29. 3. 2009, 20:57:00
Tady máte na pokusy:
<script language="JScript"> function WriteFile(filename,text) { var fso, f, r var ForReading = 1, ForWriting = 2; fso = new ActiveXObject("Scripting.FileSystemObject") f = fso.OpenTextFile(filename, ForWriting, true) f.Write(text); f.Close(); } function ReadFile(filename) { var fso, f; var ForReading = 1, ForWriting = 2; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.OpenTextFile(filename, ForReading); return(f.ReadAll()); } function read() { fi = document.getElementById("fle"); el = document.getElementById("ta"); el.innerText = ReadFile(fi.value); } function wrt() { fi = document.getElementById("fle"); el = document.getElementById("ta"); WriteFile(fi.value,el.innerText); } </script> <input type="file" id="fle"><button onclick="read();">Načíst</button><br> <textarea id="ta" style="width: 300px; height: 300px"></textarea><br> <button onclick="wrt();">Uložit</button> Funguje to jenom v IE. |
||
Časová prodleva: 15 let
|
0