Wednesday, 22 February 2023

How to detect browser in lightning component

 

How to detect browser in lightning component


This example shows usage of the $Browser global value provider.

In Lightning component 

<aura:component> {!$Browser.isTablet} {!$Browser.isPhone} {!$Browser.isAndroid} {!$Browser.formFactor} </aura: component>

In a client-side controller

({ checkBrowser: function(component) { var device = $A.get("$Browser.formFactor"); alert("You are using a " + device); } })