Newer Version Available
$Browser
The $Browser global
value provider provides 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 | Not available in all implementations. Indicates whether the browser is running on an iOS device (true) or not (false). |
| isIPad | Not available in all implementations. Indicates whether the browser is running on an iPad (true) or not (false). |
| 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 an iPad or 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). Note that this only detects Windows phones and does not detect tablets or other touch-enabled Windows 8 devices. |
Example
This example returns true or false depending on the operating system and device of the browser where you are rendering the component.
Component source
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:component>
18 {!$Browser.isTablet}
19 {!$Browser.isPhone}
20 {!$Browser.isAndroid}
21 {!$Browser.formFactor}
22</aura:component>
23Similarly, you can check browser information in a client-side controller using $A.get().
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17({
18 checkBrowser: function(component) {
19 var device = $A.get("$Browser.formFactor");
20 alert("You are using a " + device);
21 }
22})