The following editor will bring you an implementation method of using phonegap for local storage. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
The examples are as follows:
<!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>
The above is the detailed content of Introduction to how phonegap implements local storage. For more information, please follow other related articles on the PHP Chinese website!