how can i change the size of an html canvas through a function? i tried Width=123;"
and canvas.style.Width=123 canvas.width=123
neither of them worked heres the HTML code for the canvas <CANVAS id="canvas" width="460px" height="800px"></CANVAS>
and in the css canvasarea { width: 460px; height: 800px;
views:
32answers:
1
+1
A:
the <canvas>
element supports the width
attribute.
example: <canvas width="123"></canvas>
to change the width with javascript do something like:
<canvas id="myCanvas"></canvas>
<script type="javascript">
function changeCanvasWidth() {
myCanvas = document.getElementById("myCanvas");
myCanvas.style.width="123px";
}
</script>
jordanstephens
2010-08-12 00:58:03