如何在使用ActiveX时考虑非IE浏览器

时间:2014-03-26 23:35:31

标签: javascript activex

我使用以下代码写入.csv文件

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

它适用于IE。然而,对于其他浏览器,它会抛出 Uncaught ReferenceError: ActiveXObject is not defined


我在网上查了可能的解决方案

这是one of them

我尝试将该代码包含在上面的代码中,但是它没有用。

0 个答案:

没有答案