Have you ever faced a problem of identifying in which experience user is opening your page (VFP)? Is it lightning or classic.
Well, here is the solution to it. There are two ways :
1) Via Apex
public boolean isLightningExperience()
{
if(Apexpages.currentPage().getParameters().get('sfdcIFrameOrigin') != null)
return true;
return false;
}
2) Via JS on visualforce page
function isLightningExperience()
{
if('{!$Currentpage.parameters.sfdcIFrameOrigin}' != '')
return true;
return false;
}
You can use two parameters to check this 'sfdcIFrameOrigin' and 'istdp'. Now you can easily identify in which experience the user is via your code and can manipulate the functionality accordingly.
Happy Coding!!
