[英]How to write data in text file using Javascript/JQuery without ActiveXObject as it supports only IE?
I have one file ie style.css/any file whose content need to be shifted to another text file which is file.txt. 我有一个文件,即style.css /任何文件,其内容需要转移到另一个文本文件,即file.txt。 Using ActiveXObject is not working, so could you please provide any other solution.?
使用ActiveXObject无法正常工作,所以请您提供其他解决方案。
Here is my code which I tried. 这是我尝试的代码。
jQuery(function ($) {
$.get('css/style.css', function (data) {
// alert(data);
writeToFile(data);
});
function writeToFile(content) {
// alert(content);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.OpenTextFile("file.txt", 8);
fh.WriteLine(content);
fh.Close();
}
});
You can try this window.location = "data:text/html," + yourData
您可以尝试使用该
window.location = "data:text/html," + yourData
It'll dump the data in the url and force a download of the data. 它将数据转储到url中,并强制下载数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.