Javascript 文件变量声明/创建错误:此对象不支持此操作
Javascript File variable declaration/creation Error: This Object does not support this action
今天我创建了一个HTML文档来编写登录和注册网站。我的想法如下:创建帐户时,您的数据应保存在文本文件中(不安全)。登录时,代码应将输入与文件中的数据进行比较。但是,当我想为我的文件初始化变量时,Internet Explorer 显示以下错误:SCRIPT445:此对象不支持此操作。我这里有标记的行:
//Here is the layout creation...
<script>
function login()
{
var username = document.getElementById("txtusername").value;
var kennwort = document.getElementById("txtpassword").value;
}
function register()
{
var rusername = document.getElementById("txtrusername").value;
var remail = document.getElementById("txtremail").value;
var rkennwort = document.getElementById("txtrpassword").value;
var rconfirmpassword = document.getElementById("txtrconfirmpassword").value;
if(rpassword!=rconfirmpassword)
{
alert(unescape("The passwords do not match!", "Error"));
return;
}
//This line creates the error
var file = new File("C:/Users/Konsicoder/Desktop/Data/data.txt");
//This line creates the error
alert("Success!", "Success");
}
</script>
您可能需要
使用浏览器文件选择器才能首先获取本地文件的句柄,而不是提供本地文件系统路径并实例化 File 对象。
[http://www.html5rocks.com/en/tutorials/file/dndfiles/][1][使用 File API 读取 JavaScript 中的文件][1]
这是一篇关于 SO 的文章,详细介绍了如何实例化 File 对象:如何在 JavaScript 中实例化 File 对象?
相关文章:
- 对象不支持属性或方法“自动完成”
- 对象不支持对象IE 8
- 如何从 MVC4 链接调用 Javascript 方法(错误 JavaScript 运行时错误:对象不支持此操作)
- JSHint 错误“对象不支持此属性或方法”用于 javascript 闭包
- 对象不支持属性或方法“确认”
- 对象不支持属性或方法“jscomp_symbol_iterator0”
- 对象不支持 igGrid 中的属性或方法“_super”
- 下拉 Javascript 错误:对象不支持属性或方法“匹配”
- 运行时错误:对象不支持属性或方法
- 对象不支持在调用 indexOf 定义的数组时 IE8 中未定义的此属性或方法
- 对象不支持此属性或方法 Rails Windows 64 位
- IE9:对象不支持属性“is”
- Jquery说该对象不支持“每个”
- 对象不支持 IE7 jQuery 中的此属性或方法错误
- 对象不支持此属性或方法“同位素”
- 对象不支持此属性或方法 - IE 7/8
- IE 错误 .JavaScript 运行时错误:对象不支持属性或方法“preventDefault”
- 使用此 javascript 在 IE7 中收到“对象不支持此属性或方法”错误,以及选项卡未正确定位的问题
- 在 IE6 中运行时添加 CSS 规则 - 对象不支持此属性或方法
- 对象不支持属性或方法“jtable”