Enter or request fullscreen?

Recently I encountered this "wonderful" device specific issue where this Android device was old, we arent talking that old but older. Running I think 4.2.2 or so. Well the issue that I was encountering was to make the video go fullscreen and for some reason it just wouldnt take from javascript. Well of course I had written such error safe javascript that the actual issue which took me a while to encounter was that a method I expected to exist didnt. Also the best part was that my chrome inspector was not inspecting other Android connected devices that day. Well what I ended up finding was that the api that needed to be used for fullscreen was the older deprecated webkitEnterFullScreen.

So what I found was that while we have request fullscreen available to us and also enterfullscreen, a check needs to go through the request full screens that are available first and then lastly if none of those can be found then you must fallback to using enterFullScreen. Below is an example.

    function goFullScreen(elem) {
      if (elem) {
        if (elem.requestFullScreen) {
        } else if (elem.mozRequestFullScreen) {
        } else if (elem.webkitRequestFullScreen) {
        } else if (elem.webkitEnterFullScreen) {
        } //Add any capitilization issue checks such as s be lower case or upper case.

So there you have it. The true answer to the question of whether to use enter or request is to use both, first attempting request fullscreen then falling back to enter fullscreen.

Happy coding readers.