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 に答える