localDevice Object Reference

Table of contents


Introduction

The localDevice object provides properties about the platform that the app is executing on.


Global identifiers

localDevice

localDevice is a global variable (var localDevice) defined by a classic script loaded with a <script> tag. It is not exported from a module and needs no import.


localDevice properties

isAndroid

True if the app is running on an Android device.

Value

A Boolean.


isIOS

True if the app is running on an Apple iOS device (iPhone or iPad).

Value

A Boolean.


isLocalhost

True if the app is running in a browser from local (localhost) server.

Value

A Boolean.


isNative

True if the app is running in any Cordova host (window.cordova exists), i.e. as a native app.

Value

A Boolean.


isTouch

True if the device is touch capable (ontouchstart is supported or the user agent contains Touch). This includes any touch-capable device, not only mobile devices.

Value

A Boolean.


isWebApp

True if the app is running as a standalone home-screen web app (navigator.standalone) and is not native.

Value

A Boolean.


missing

A string containing important missing features in the app environment, determined from Modernizr tests. The features are separated by '+'. The possible features are:

Value

A string.


platform

A string indicating the current platform. The possible strings are:

Value

A string.


strings

An object of descriptive strings, derived with UAParser, for diagnostics:

Value

An object of strings.


viewHeight()

Returns the viewport height in pixels in the current orientation: the larger of document.documentElement.clientHeight and window.innerHeight.

Value

A number.


viewWidth()

Returns the viewport width in pixels in the current orientation: the larger of document.documentElement.clientWidth and window.innerWidth.

Value

A number.


portHeight()

Returns the viewport height in portrait orientation: the larger of viewWidth() and viewHeight().

Value

A number.


portWidth()

Returns the viewport width in portrait orientation: the smaller of viewWidth() and viewHeight().

Value

A number.