gpt4 book ai didi

javascript - 使用 JavaScript 将数据写入 CSV 文件

转载 作者:行者123 更新时间:2023-11-27 23:49:33 25 4
gpt4 key购买 nike

我想将表单中的数据结果写入 csv(或 excel)。我想将这个结果保存在无服务器服务器中(没有php等)。

我找到了这段代码:

<html>
<head>
<script language="javascript">
function WriteToFile(passForm) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileLoc = "C:\\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。

如何解决这个问题?

问候

最佳答案

当我理解你的问题并进行搜索时,我发现

ActiveX is only supported by IE - the other browsers use a plugin architecture called NPAPI. However, there's a cross-browser plugin framework called Firebreath that you might find useful.

你可以引用这个问题

refer question 1

refer question 2

关于javascript - 使用 JavaScript 将数据写入 CSV 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32844720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com