首页 > 代码库 > 使用phonegap进行本地存储

使用phonegap进行本地存储

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>Database Example</title>

		<script type="text/javascript" charset="UTF-8" src="http://www.mamicode.com/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进行本地存储