1
我不能将数据从IE写入本地文件。我有一个问题:当我创建一个内容JScript,将数据写入文件从IE
<html>
<head>
<title>File's saving</title>
<SCRIPT>
function cf_random() {
b="c:\\file.txt";
var fso, f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.CreateTextFile(b, true);
f1.WriteLine("Testing") ;
document.writeln("File " + b + " is created.");
}
</SCRIPT>
</head>
<BODY>
<input type=button value="Create file" onClick="cf_random()">
</body>
</html>
它的伟大工程,但是当我尝试的extern js文件相同的代码,我用书签连接到网站的HTML页面 - 我得到一个错误SCRIPT429:自动化服务器无法创建对象(代码如下)
javascript: (function() {
var s2 = document.createElement('script');
s2.src = 'http://192.168.0.100/jquery.js';
document.body.appendChild(s2);
})();
$(document).ready(function(){
b="c:\\file.txt";
var fso, f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.CreateTextFile(b, true);
f1.WriteLine("Testing") ;
document.writeln("File " + b + " is created.");
});
什么可能是错误的?
我不会建议使用脚本写入客户机上的文件。 –
我试着解释一下。这是我不会在我的网站上使用的代码。这是代码,它只是为我的本地机器。我尝试使用js代码解析当前在我的浏览器中加载的网页(不是我的网页,例如它可以是谷歌网页),而是将obteined结果写入extern文件。所以我需要写入文件。 – abilash
也许这会帮助吗? http://stackoverflow.com/questions/10193532/javascript-how-to-append-data-to-a-file –