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 396 views
1 answer 218 views
218 views asked May 25, 2016 by avibootz
1 answer 210 views
210 views asked May 25, 2016 by avibootz
2 answers 352 views
1 answer 199 views
199 views asked Nov 22, 2018 by avibootz
1 answer 240 views
...