I have seen dozens of tutorials on this, and it seems straight forward. All I want is to make my HTML5 canvas element go full-screen (as in total full-screen, taking up the whole monitor).
Here's my HTML:
<p><canvas id="screen" width="800" height="500"
style="background: #FFFFFF; border: 5px solid black;" role="img">
Your browser does not support the canvas element.
</canvas></p>
<p><a href="javascript:goFullScreen();">Go Fullscreen</a></p>
Here's my Javascript (in its own .js file):
function goFullScreen(){
var canvas = document.getElementById("screen");
if(canvas.requestFullScreen)
canvas.requestFullScreen();
else if(canvas.webkitRequestFullScreen)
canvas.webkitRequestFullScreen();
else if(canvas.mozRequestFullScreen)
canvas.mozRequestFullScreen();
}
I tested the function; it gets called and one of the three ifs (namely, since I'm using Firefox, mozRequestFullScreen) gets called. My browser opens it up on every demo that I've tested, but not in my own code.
What's the missing variable? I must have Googled literally every link that mentions this, and still nothing. Thanks.
To make canvas fill the whole page, you need to be 100% in width and height of the page.
Shift-click to zoom out. Mousewheel up/down over the canvas to zoom in to/out from that location. By redrawing the canvas at different scales the strokes remain smooth during zooming.
In the Properties panel, you can input canvas size width and height at specific values. Use the Units property to change the canvas size units between pixels, inches, or centimeters. Use the Resolution setting to set a print resolution in pixels/inch or pixels/centimeter.
position:absolute You can also use position absolute as well as setting all the viewport sides (top, right, bottom, left) to 0px. This will make the div take the full screen.
Okay, I found the problem. This does not work:
<p><a href="javascript:goFullScreen();">Go Fullscreen</a></p>
This DOES work:
<p><button onclick="goFullScreen();">Go Fullscreen</button></p>
Yeah... 3 hours later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With