How can I check if an element is in fullscreen with the fullscreen API for HTML5

html, javascript

Solution

I found out how to do it after playing around a little:

function fs_status() {
    if (document.fullscreenElement || document.webkitFullscreenElement ||
        document.mozFullScreenElement)
            return 1;
    else
            return -1;
}

Problem

The question is pretty much in the title. I want to return a value that tells me whether or not the element in question is in fullscreen. How do I do that using javascript? This seems to not work: ``` function fs_status() { var fullscreenElement = canvas.fullscreenElement ||canvas.mozFullscreenElement || canvas.webkitFullscreenElement; return fullscreenElement; } ``` //Sorry, I don't really understand js. So if your making an example can you please use 'canvas' as the element in question.

Original source