实例如下:
<!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进行本地存储的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。