2014-03-12 57 views
0

如何使用Phonegap將html寫入文本文件?我正在嘗試遵循API文檔中的示例。文件創建工作,但我不能讓console.log工作。如何使用Phonegap將console.log()html

function gotFS(fileSystem) { 
    fileSystem.root.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry, fail); 
} 

function gotFileEntry(fileEntry) { 
    fileEntry.createWriter(gotFileWriter, fail); 
} 

function gotFileWriter(writer) { 
    writer.onwriteend = function(evt) { 
     console.log($("h1"));   
    }; 
} 

function fail(error) { 
    console.log(error.code); 
} 

<body> 
    <h1>Example</h1> 
    <p>Write File</p> 
    </body> 
+1

'的console.log()'不會寫入一個文本文件,它只能輸出到JavaScript控制檯信息。 – MBillau

+1

我應該一直使用WRITER.WRITE()而不是console.log() – Yerpasaur

回答

0

改爲使用「document.write」。它爲我工作。

+0

文件系統在新的Android OS上的工作方式是否不同?它似乎在2.2上寫得很好,但沒有寫在4.4上。 – Yerpasaur

+0

我也是新手phonegap,所以沒有太多的想法。 – Anjy786

0

嘗試使用

Log.d("info", "YOUR_TEXT");

相關問題