<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Database Example</title>
<script type="text/javascript" charset="UTF-8" src="cordova.js"></script>
<script type="text/javascript" charset="UTF-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
}
function storeName(){
var myName=document.getElementById("name").value;
window.localStorage.setItem("name",myName);//存儲
var result=document.getElementById("result");
result.innerHTML="Your name is"+window.localStorage.getItem("name");//取出存儲值
return false;
}
</script>
</head>
<body>
<form>
<p>What is your name?<br />
<input type='text' id='name' onkeyup='storeName()'></p>//鍵盤彈起
<input type='text' id='name' onblur='storeName()'></p>//焦點移到輸入框外
</form>
<div id='result'>show content</div>
</body>
</html>
以上這篇使用phonegap進(jìn)行本地存儲的實現(xiàn)方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。