I'm having some problems trying to use short circuiting on a web page I am making.
I am trying to use
document.webkitExitFullscreen() || document.mozCancelFullScreen() || document.exitFullScreen();
But it seems to stop on the first try, despite that I would have though it would continue after the first argument comes up as undefined.
If I simply type in
document.mozCancelFullScreen()
then it works fine
I was wondering if anyone could point me to what I'm doing wrong here The screenshot is taken in firefox btw. Thanks in advance
Your code is trying to call
document.webkitExitFullscreen
and if it returns a falsy value, calldocument.mozCancelFullScreen
, etc.But if
document.webkitExitFullscreen
itself isundefined
you'll get an error trying to call it, and the code will stop running at that point.Perhaps:
Or alternatively:
...which avoids the whole "do I need
call
or not?" issue.