下面小编就为大家带来一篇使用phonegap进行本地存储的实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
实例如下:
<!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> <p id='result'>show content</p> </body> </html