Utility methods to detect current platform.
These methods are called directly on the DOM element. Get a reference to the element in JS, and the methods below will be available to call on it. For example: document.querySelector('ons.platform').someMethod()
.
Signature | Description |
---|---|
select(platform) | Sets the platform used to render the elements. Useful for testing. |
isWebView() | Returns whether app is running in Cordova. |
isIPhone() | Returns whether the device is iPhone. |
isIPhoneX() | Returns whether the device is iPhone X, XS, XS Max, XR, 11, 11 Pro, 11 Pro Max, 12 Mini, 12, 12 Pro or 12 Pro Max, 13 Mini, 13, 13 Pro, 13 Pro Max, 14, 14 Plus, 14 Pro, 14 Pro Max. |
isIPad() | Returns whether the device is iPad. |
isIOS([forceActualPlatform]) | Returns whether the OS is iOS. By default will return manually selected platform if it is set. |
isIOS7above() | Returns whether the iOS version is 7 or above. |
isIPadOS() | Returns whether the OS is iPadOS. |
isIOSSafari() | Returns whether app is running in iOS Safari. |
isWKWebView() | Returns whether app is running in WKWebView. |
isAndroidPhone() | Returns whether the device is Android phone. |
isAndroidTablet() | Returns whether the device is Android tablet. |
isAndroid([forceActualPlatform]) | Returns whether the OS is Android. By default will return manually selected platform if it is set. |
isWP([forceActualPlatform]) | Returns whether the OS is Windows phone. By default will return manually selected platform if it is set. |
isBlackBerry([forceActualPlatform]) | Returns whether the device is BlackBerry. By default will return manually selected platform if it is set. |
isOpera([forceActualPlatform]) | Returns whether the browser is Opera. By default will return manually selected platform if it is set. |
isFirefox([forceActualPlatform]) | Returns whether the browser is Firefox. By default will return manually selected platform if it is set. |
isSafari([forceActualPlatform]) | Returns whether the browser is Safari. By default will return manually selected platform if it is set. |
isChrome([forceActualPlatform]) | Returns whether the browser is Chrome. By default will return manually selected platform if it is set. |
isIE([forceActualPlatform]) | Returns whether the browser is Internet Explorer. By default will return manually selected platform if it is set. |
isEdge([forceActualPlatform]) | Returns whether the browser is Edge. By default will return manually selected platform if it is set. |
Sets the platform used to render the elements. Useful for testing.
Name | Type | Description |
---|---|---|
platform | string | Possible values are: “opera”, “firefox”, “safari”, “chrome”, “ie”, “android”, “blackberry”, “ios” or “wp”. |
Returns whether app is running in Cordova.
Returns whether the device is iPhone.
Returns whether the device is iPhone X, XS, XS Max, XR, 11, 11 Pro, 11 Pro Max, 12 Mini, 12, 12 Pro or 12 Pro Max, 13 Mini, 13, 13 Pro, 13 Pro Max, 14, 14 Plus, 14 Pro, 14 Pro Max.
Returns whether the device is iPad.
Returns whether the OS is iOS. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the iOS version is 7 or above.
Returns whether the OS is iPadOS.
Returns whether app is running in iOS Safari.
Returns whether app is running in WKWebView.
Returns whether the device is Android phone.
Returns whether the device is Android tablet.
Returns whether the OS is Android. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the OS is Windows phone. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the device is BlackBerry. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the browser is Opera. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the browser is Firefox. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the browser is Safari. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the browser is Chrome. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the browser is Internet Explorer. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
Returns whether the browser is Edge. By default will return manually selected platform if it is set.
Name | Type | Description |
---|---|---|
forceActualPlatform | Boolean | If true, selected platform is ignored and the actual platform is returned. |
If you have any questions, use our Community Forum or talk to us on Discord chat. The Onsen UI team and your peers in the community will work together to help solve your issues.
For bug reports and feature requests use our GitHub Issues page.