HTML and CSS Reference
In-Depth Information
HTML5 Event Attributes
onabort, onblur, oncanplay, oncanplaythrough, onchange, onclick,
oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave,
ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended,
onerror, onfocus, onformchange, onforminput, oninput, oninvalid, onkeydown,
onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart,
onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel,
onpause, onplay, onplaying, onprogress, onratechange, onreadystatechange,
onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit,
onsuspend, ontimeupdate, onvolumechange, onwaiting
API Reference
A brief overview of the canvas scripting API is provided in Tables 3-9 through 3-21. Selected
examples of use can be found in Chapter 2.
<canvas id="canvas1" height="400" width="400">
<p class="error"> Canvas-Supporting Browser Required </p>
<script type="text/javascript">
var canvas = document.getElementById("canvas1");
var context = canvas.getContext("2d");
/* draw simple figure of red and green squares */
context.fillStyle = "rgb(255,0,0)";
context.fillStyle = "rgb(0,255,0)";
Returns an object that exposes
the API necessary for accessing
the drawing functions. Currently,
the only contextId is '2d' .
var context = canvas
toDataUrl([type]) Returns a data: URL of the
canvas image as a file of the
specified type or a PNG file by
var dataurl = canvas
Height of the canvas element.
Default value is 150 .
var canvas = document
canvas.height = 300;
Width of the canvas element.
Default value is 300 .
var canvas = document
canvas.width = 600;
T ABLE 3-9 Primary canvas Methods and Properties
Search WWH ::

Custom Search