Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
$Browser
The $Browser global value
provider returns information about the hardware and operating system of the browser
accessing the application.
| Attribute | Description |
|---|---|
| formFactor | Returns a FormFactor enum
value based on the type of hardware the browser is running on.
|
| isAndroid | Indicates whether the browser is running on an Android device (true) or not (false). |
| isIOS | Due to changes made by Apple, isIOS is deprecated because it no longer distinguishes between iPad and MacOS desktop. |
| isIPad | Due to changes made by Apple, isIPad is deprecated because it no longer distinguishes between iPad and MacOS desktop. |
| isIPhone | Not available in all implementations. Indicates whether the browser is running on an iPhone (true) or not (false). |
| isPhone | Indicates whether the browser is running on a phone including a mobile phone with a browser and a smartphone (true), or not (false). |
| isTablet | Indicates whether the browser is running on a tablet with Android 2.2 or later (true) or not (false). |
| isWindowsPhone | Indicates whether the browser is running on a Windows phone (true) or not (false). This attribute detects only Windows phones and doesn’t detect tablets or other touch-enabled Windows 8 devices. |
Example
This example shows usage of the $Browser global value provider.
1<aura:component>
2 {!$Browser.isTablet}
3 {!$Browser.isPhone}
4 {!$Browser.isAndroid}
5 {!$Browser.formFactor}
6</aura:component>Similarly, you can check browser information in a client-side controller using $A.get().
1({
2 checkBrowser: function(component) {
3 var device = $A.get("$Browser.formFactor");
4 alert("You are using a " + device);
5 }
6})