How to set HTML canvas to full screen size in JavaScript

1 Answer

0 votes
<canvas id="canvas"></canvas>
<script type="text/JavaScript">   

var canvas = document.getElementById("canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

var ctx = canvas.getContext("2d");
ctx.font = "12px Arial";
ctx.fillText(canvas.width + ' - ' + canvas.height ,30, 30);

</script>

 



answered May 27, 2016 by avibootz

Related questions

1 answer 510 views
1 answer 310 views
310 views asked May 25, 2016 by avibootz
1 answer 304 views
304 views asked May 25, 2016 by avibootz
2 answers 479 views
1 answer 287 views
287 views asked Nov 22, 2018 by avibootz
1 answer 349 views
...