<!DOCTYPE HTML>
<html>
<body>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>
<script type="text/javascript">
function Pause(obj,s){
this.GoOn = function(n,obj,s){
if(n == 0){
setTimeout(function(){GoOn(1,obj,s);},s);
} else{
obj.NextStep();
}
}
this.GoOn(0,obj,s);
}
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.moveTo(20,20);
Pause(this,1000);
this.NextStep = function(){
cxt.lineTo(180,80);
cxt.stroke();
Pause(this,1000);
this.NextStep = function(){
cxt.lineTo(20,80);
cxt.stroke();
Pause(this,1000);
this.NextStep = function(){
cxt.lineTo(20,20);
cxt.stroke();
}
}
}
if (localStorage.lastname){
localStorage.lastname=Number(localStorage.lastname) +1;
}else{
localStorage.lastname=‘1‘;
}
document.write(localStorage.lastname);
if (sessionStorage.pagecount){
sessionStorage.pagecount=Number(sessionStorage.pagecount) +1;
}else{
sessionStorage.pagecount=1;
}
document.write("Visits "+sessionStorage.pagecount+" time(s) this session.");
</script>
</body>
</html>
html5画图和本地存储