0

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 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

Community
  • 1
  • 1
  • didn't get you? what you want??, do : `body +=body+/*some string*/` – diEcho May 23 '11 at 12:21
  • 2
    Javascript running in a browser doesn't have access to the underlying file system for security reasons, but this could be accomplished if you're talking about server-side JS (such as node.js). Are you? :) – chrisfrancis27 May 23 '11 at 12:22
  • @Chris - not strictly true. Permissions can be given and IE can use WSH FileSystemObject in HTA – mplungjan May 23 '11 at 12:25

3 Answers3

1

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

Alex
  • 29,618
  • 13
  • 100
  • 157
0

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

DanBeale
  • 312
  • 4
  • 15
James McCormack
  • 9,048
  • 3
  • 46
  • 55
0

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

Ravi Parekh
  • 4,533
  • 8
  • 41
  • 55