close

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Sample</title>
<script src="cordova-2.7.0.js" type="text/javascript"></script>
<script type="text/javascript">
if (!navigator.userAgent.toLowerCase().match('chrome')) {
document.write("<script src='phonegap.js'><\/script>");
}
</script>
</head>
<body onload="onLoaded()">
<div class="info" style="font-size:12px">CCN TEST</div>
<script>
function onLoaded() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError);
}
function onSuccess(fileSystem){
fileSystem.root.getFile("ccn_example.txt",
{create: true, exclusive: false},
onCreateSuccess, onCreateError);
alert('requestFileSystem success!');
}
function onError(err){
alert('onError');
}
function onCreateSuccess(fileEntry){
alert('成功創建檔');
//entry.getParent(onGetPsuccess,onGetPerror);
fileEntry.createWriter(onGetFileWriterSuccess,
onGetFileWriterError);
}

function onCreateError(err){
alert('onCreateError');
}
function onGetFileWriterSuccess(writer){
alert('onGetFileWriteSuccess');
writer.onwrite = onWriteSuccess;
writer.onerror = onWriteError;
writer.write("Some text to the file");
}
function onGetFileWriterError(err){
alert('onGetFileWriteError');
}
function onWriteSuccess(evt){
alert('成功寫入檔!');
}
function onWriteError(evt){
alert('onWriteError:'+evt.target.error.code);
}
</script>
</body>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()