ved*_*t13 6 javascript firefox file-io
情况: - 我创建了一个返回URL的安装设置(本地),例如: - ved.test.com,映射到IP 11.22.33.44.因此,要在安装后使Web应用程序可访问,用户必须明确地在"C:\ WINNT\system32\drivers\etc"目录下的hosts文件中创建一个条目.
方法: - 安装应用程序完成后,应用程序使用Javascript写入文件.
问题: - IE支持使用Javascript编写文件.我需要一个Firefox解决方案.使用的代码: -
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Write To A File</title>
<script language="javascript">
function WriteToFile()
{
/* The below statement is supported in IE only */
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\Test.txt", true);
s.WriteLine('IE Supports Me!');
s.Close();
}
</script>
</head>
<body onLoad="WriteToFile()">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
还提到了SO中的链接: - 如何使用JavaScript读写文件
请提供支持使用在Firefox浏览器中运行的Javascript编写文件的解决方案.
提前致谢.
Nic*_*ver 14
出于明显的安全原因,你无法做到这一点.JavaScript无法访问文件系统...在IE中它不是JavaScript,而是ActiveX这样做......它只是暴露了一个JavaScript API.
问题不在于Firefox没有这样做......这就是IE曾经允许它:)
| 归档时间: |
|
| 查看次数: |
15452 次 |
| 最近记录: |