Skip to content Skip to sidebar Skip to footer

How To Write A Variables's Content To A File In JavaScript

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 want some simp

Solution 1:

Due to security restrictions you can not write local files using Javascript.


Solution 2:

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


Solution 3:

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


Post a Comment for "How To Write A Variables's Content To A File In JavaScript"