[英]Javascript How to Create and Write to Local txt file
Need expert ideas how to Create and Write to .txt file on JavaScript. 需要有关如何在JavaScript上创建和写入.txt文件的专家意见。 I am using below code it works fine with IE but not on Chrome with error as "ActiveXObject" undefined.
我正在使用以下代码,它可以在IE上正常运行,但在Chrome上无法正常运行,错误为“ ActiveXObject”未定义。 "ActiveXObject" related to IE specific not supported on Chrome.
Chrome不支持与IE相关的“ ActiveXObject”。
var myObject = new ActiveXObject("Scripting.FileSystemObject");
I have checked few comments related to similar issue and i also tried using below options: 我检查了与类似问题相关的一些评论,我也尝试使用以下选项:
set fso = CreateObject("Scripting.FileSystemObject");
set s = fso.CreateTextFile("C:\test.txt", True);
var reader = new FileReader();
reader.onload = function(e)
Still issue persists. 问题仍然存在。 Need support how to write code in javascript which can be Browser independent (can execute on IE, CHrome and FF) .
需要支持如何在JavaScript中编写代码,该JavaScript可以与浏览器无关(可以在IE,CHrome和FF上执行)。
function WriteToFile(passForm) { set fso = CreateObject("Scripting.FileSystemObject"); set s = fso.CreateTextFile("C:\\test.txt", True); s.writeline("HI"); s.writeline("Bye"); s.writeline("-----------------------------"); s.Close(); }
<body> <p>To sign up for the Excel workshop please fill out the form below: </p> <form onSubmit="WriteToFile(this)"> Type your first name: <input type="text" name="FirstName" size="20"> <br>Type your last name: <input type="text" name="LastName" size="20"> <br> <input type="submit" value="submit"> </form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.