O'Reilly logo

iPhone JavaScript Cookbook by Arturo Fernandez Montoro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting full screen or browser mode

As you've learned in the previous recipe, an application can run in full screen or in browser mode. By default, web applications will run on the second one, that is, in the browser mode. Because it's possible to run applications in these two modes, it could be useful to detect which mode is running. Let's explore how to do it.

How to do it...

  1. We're going to use only JavaScript code to detect the running mode for our application. You can use a simple HTML page with the following code inside the<head> section:
    <script type="text/javascript" charset="utf-8">
    var mode = 'browser';
    if (navigator.standalone) {
    mode = "standalone";
    }
    alert("App. running in " + mode + " mode");
    </script>
    

    For testing our JavaScript code, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required