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 .