0

I am using the following code to write to a .csv file

<html>
  <head>
  <script language="javascript">
    function WriteToFile(passForm) {
      var fso = new ActiveXObject("Scripting.FileSystemObject");
      var fileLoc = "C:\\Users\\Owner\\Desktop\\test\\sample.csv";
      var file = fso.CreateTextFile(fileLoc, true ); 
      file.writeline(passForm.FirstName.value + ',' + passForm.LastName.value);
      file.Close();
      alert('File created successfully at location: ' + fileLoc);
     }
  </script>
  </head>
  <body>
  <p>create a csv file with following details -</p>
  <form>
    Type your first name: <input type="text" name="FirstName" size="20">

    Type your last name: <input type="text" name="LastName" size="20">

    <input type="button" value="submit" onclick="WriteToFile(this.form)">
  </form>
  </body>
</html>
</br></br></html>

It works perfect for IE . However for other browsers it throws Uncaught ReferenceError: ActiveXObject is not defined


I checked online for possible solutions

Here is a one of them

I tried to include that code into the above code , however it did not work .

Community
  • 1
  • 1
  • 1
    Other browsers will not allow regular web page javascript to write to your file system for security reasons. – jfriend00 Mar 26 '14 at 23:46
  • On a different note, the _language_ attribute of ` – Paul S. Mar 27 '14 at 00:38

0 Answers0