0

I want that when the user presses the div, a new file will be created and the line: Testing 1, 2, 3. will be inserted.

I tried the next thing:

<div  id="rect0" onclick="CreateFile();" style="height: 85px; width: 85px; background-color:#ff0000; ">Hello</div>

<script>
    function CreateFile()
    {
       var fso, tf;
       fso = new ActiveXObject("Scripting.FileSystemObject");
       tf = fso.CreateTextFile("c:\\Log\\logJscript2.txt", true);

       tf.WriteLine("Testing 1, 2, 3.") ;

       tf.Close();
    }
</script>
6
  • 1
    ActiveXObject just works on IE Commented Jun 18, 2013 at 14:27
  • Which browser and version are you targeting? Commented Jun 18, 2013 at 14:27
  • So, you've done this, what's the problem? The snippet is correct (though for IE only). What you want to ask? Commented Jun 18, 2013 at 14:30
  • I want it to work on Chrome. Commented Jun 18, 2013 at 14:34
  • I found this link: svn.tiddlywiki.org/Trunk/core/jquery/plugins/jQuery.twFile.js what should I write in my javascript file? $.twFile.save("c:\\Log\\logJscript2.txt", "my line"); Commented Jun 18, 2013 at 14:36

1 Answer 1

2

Sorry, JavaScript cannot do this. It's a huge security issue if it could. Imagine a browser downloading any file it likes without the user knowing about it like you propose here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.