<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<button id="btn">按我</button>	
	<div id="result"></div>
	<a href="http://www.google.com">先去一下google再回來按</a>
	<script type="text/javascript">
		if(!localStorage['clickcount']){
			var i =0;
		}else{
			i=localStorage['clickcount'];
		}
		document.getElementById('btn').onclick=function(){
			i++;
			localStorage.setItem('clickcount',i);
			for (var j = 0; j < localStorage.length; j++) {
				document.getElementById('result').innerHTML='<h2>localSotorage的「'+localStorage.key(j)+'」欄位紀錄的資料是「'+localStorage.getItem(localStorage.key(j))+'」</h2>';
			}
		}
	</script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<button id="btn">按我</button>	
	<div id="result"></div>
	<a href="http://www.google.com">先去一下google再回來按</a>
	<script type="text/javascript">
		if(!sessionStorage['clickcount']){
			var i =0;
		}else{
			i=sessionStorage['clickcount'];
		}
		document.getElementById('btn').onclick=function(){
			i++;
			sessionStorage.setItem('clickcount',i);
			for (var j = 0; j < sessionStorage.length; j++) {
				document.getElementById('result').innerHTML='<h2>sessionSotorage的「'+sessionStorage.key(j)+'」欄位紀錄的資料是「'+sessionStorage.getItem(sessionStorage.key(j))+'」</h2>';
			}
		}
	</script>
</body>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Jerry 的頭像
    Jerry

    Bug倉庫 // 程式日記

    Jerry 發表在 痞客邦 留言(0) 人氣()