1

I have one file i.e style.css/any file whose content need to be shifted to another text file which is file.txt. Using ActiveXObject is not working, so could you please provide any other solution.?

Here is my code which I tried.

jQuery(function ($) {
    $.get('css/style.css', function (data) {
      //  alert(data);
        writeToFile(data);
    });

    function writeToFile(content) {
      //  alert(content);
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var fh = fso.OpenTextFile("file.txt", 8);
        fh.WriteLine(content);
        fh.Close();

    }
});
4
  • You have a couple of options, the easiest option would be plain HTML5 and Javascript. thiscouldbebetter.wordpress.com/2012/12/18/… Also your question sounds very demanding maybe change it a bit Commented Jun 15, 2015 at 12:29
  • 1
    Why? Whatever you are trying to do it sounds like you are doing it wrong. Commented Jun 15, 2015 at 12:31
  • Please check this stackoverflow.com/questions/21012580/… Commented Jun 15, 2015 at 12:32
  • I believe this is an X/Y problem - also your ActiveX would likely work in an HTA Commented Jun 15, 2015 at 12:38

1 Answer 1

1

You can try this window.location = "data:text/html," + yourData

It'll dump the data in the url and force a download of the data.

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.