Possible Duplicate:
firefox: How to enable local javascript to read/write files on my PC?
Consider the JavaScript code:
var body=" ";
body=body+/*some string*/
I wan开发者_开发知识库t some simple way to write this content (var body
in this code) to a file in local computer.
Please help me out in doing this job.
Thanks
Due to security restrictions you can not write local files using Javascript.
For this, In your script section add:
try{var wsh = new ActiveXObject('WScript.Shell');} catch(err){}
This will promp user to enable Activex.
Then you can run any of the command using:
wsh.Run("notepad.exe"); //OR
wsh.Run("echo asdfasf sFAS > a");
may be it works for you NOTE: i used ActiveXObject that means it works in IE only
JavaScript on a web page cannot write a file to the local computer.
There is some scope for this in HTML 5, but it's not widely supported yet: http://diveintohtml5.ep.io/storage.html
精彩评论