Form
<canvas> ... </canvas>
Attributes
attribute |
default |
description |
id |
none |
specifies the unique ID |
class |
none |
specifies the style sheet class |
style |
none |
specifies the style sheet |
width |
none |
specifies the width |
height |
none |
specifies the height |
Support
[Firefox 1.5 or later][Safari 2 or later][Opera 9 or later]
Explanation
The canvas tag indicates the canvas on which you can draw a graphic as you like. You draw on the canvas using JavaScript. See
<canvas> tag reference for details.
The canvas tag is supported by Safari 2, Firefox 1.5 and Opera 9 or later. In Safari 2, it works without adding the eclosing tag while other browsers requires it.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=shift_jis">
<title>Sample</title>
<script type="text/javascript"><!--
function drawPoint()
{
canvasObj = document.getElementById("imgCanvas");
conObj = canvasObj.getContext("2d");
x = Math.floor(Math.random() * 320);
y = Math.floor(Math.random() * 240);
conObj.fillStyle = "rgba(0,0,255,0.5)";
conObj.fillRect(x,y,10,10);
}
// --></script> </head>
<body onload="setInterval('drawPoint()',100)">
<h1>Sample</h1>
<canvas id="imgCanvas" width="320" height="240" style="border:1px black solid"></canvas>
</body>
</html>