日期:2014-05-16 浏览次数:20623 次
<body> <canvas id="myCanvas" width="300px;" height="200px" style="border:1px solid #00ff00;"></canvas> <script type="text/javascript"> var c=document.getElementById("myCanvas"); var cxt=c.getContext("2d"); cxt.moveTo(0,0); cxt.lineTo(150,60); cxt.lineTo(10,60); cxt.stroke(); </script> <hr> <br> <canvas id="myCanvas2" width="300px;" height="200px"style="border:1px solid #00ff00;"></canvas> <script type="text/javascript"> var c=document.getElementById("myCanvas2"); var cxt=c.getContext("2d"); cxt.fillStyle="#ff0000"; cxt.beginPath(); cxt.arc(70,18,15,0,Math.PI*2,true);//画弧context.arc(x, y, radius, startAngle, endAngle, anticlockwises) cxt.closePath(); cxt.fill(); </script> </body>
localstorage基本使用方法如下:默认存数的是字符串类型
if(localStorage.pageCount){ localStorage.pageCount=Number(localStorage.pageCount)+1;//pageCount自定义的 } else{ localStorage.pageCount=1; } document.write("visit"+localStorage.pageCount+"time(s)"); </script>