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 504 views
1 answer 303 views
303 views asked May 25, 2016 by avibootz
1 answer 299 views
299 views asked May 25, 2016 by avibootz
2 answers 473 views
1 answer 285 views
285 views asked Nov 22, 2018 by avibootz
1 answer 347 views
...