问题包括我对Javascript afaik缺乏了解。 我写的时候:
function startOnDevice(){
var path = document.addEventListener("deviceready", onDeviceReady, true);
}
我怎样才能传递文件名称的“字符串”? (ei。到onDeviceReady,然后再往下走。
然后传递给onDeviceReady。它需要传递给onFSSuccess:
function onDeviceReady() {
//what do we have in cache already?
$("#status").html("Checking your local cache....");
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFSSuccess, null);
}
function onFSSuccess(fileSystem) {
fileSystem.root.getDirectory("dk.lector.html5Generic",{
create:true
},gotDir,onError);
}
然后onFSSuccess需要以某种方式将值返回给变量路径。
任何帮助?
答案 0 :(得分:1)
好的,这是一个新版本,因为您更新了问题中的代码:
var file = "foo.txt";
function onDeviceReady() {
//what do we have in cache already?
$("#status").html("Checking your local cache....");
alert("file is " + file);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function (fileSystem) {
onFSSuccess(fileSystem, file); // use file variable from above and pass as second param.
}, null);
}
function onFSSuccess(fileSystem, file) {
alert("file is " + file);
fileSystem.root.getDirectory("dk.lector.html5Generic",{
create:true
},gotDir,onError);
}