0

问题在于我对 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 需要以某种方式将值返回给变量路径。

有什么帮助吗?

4

1 回答 1

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);
}
于 2012-07-18T09:41:40.200 回答