<html>
<body>
<canvas id="myCanvas" width="200" height="200" style="border:1px solid">
您的浏览器不支持 HTML5 canvas 标签。
</canvas>
<br>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="#92B901";
ctx.fillRect(50,50,100,100);
function clearCanvas()
{
c.height=300;
}
</script>
<button onclick="clearCanvas()">Clear canvas</button>
</body>
</html>