我正在开发Android应用程序,我需要访问FileSystem。当我运行该页面时,我收到错误"无法读取属性' name'未定义"。这是我的网页代码
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!--<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />-->
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.3.2.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/fullcalendar.css" />
<link rel="stylesheet" type="text/css" href="css/fullcalendar.print.css" />
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.3.2.min.js"></script>
<script src="js/fullcalendar.js"></script>
<script src="js/gcal.js"></script>
<script src="js/phonegap-1.4.1.js"></script>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-3.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady);
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess(), fail);
}
function onFileSystemSuccess(fileSystem) {
alert('test');
try {
var fs = fileSystem.name;
alert(String(fs));
var directoryEntry = fileSystem.root;
alert(directoryEntry.fullPath);
console.log(fileSystem.root.name);
} catch(err) {
alert(err.message);
}
}
function test() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess(), fail);
}
function fail(evt) {
console.log(fail.target.error.code);
alert(evt.target.error.code);
}
</script>
</head>
<body>
<div id="header" data-role="header" >
<a hrefeader="#" data-icon="back" data-rel="back" title="Go back">Back</a>
</div>
<div id="content" data-role="content">
<a data-role="button" rel="external" onclick="test()" >Test Local Storage</a>
</div>
</body>
我的手机版本是3.0.0-0.14.3 任何人都可以帮助我或告诉我做错了什么?
答案 0 :(得分:0)
您不能将括号传递到requestFileSystem
,因为它需要带参数的函数。请改用:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
// ^^