function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kanwalpreet SinghKanwalpreet Singh 

Apex how to check view is Salesforce Classic or Lightning.


How i can check on controller if page is opened using 'Salesforce Classic' or 'Salesforce lightning' UI(for winter 16 release).

Kanwalpreet Singh
ShashankShashank (Salesforce Developers) 
I'm sure this will help you:
with javascript you can do that :
        if(document.referrer.indexOf("") > 0){
            alert("welcome to lightning ");
            alert("welcome to classic");
FYI: This is now built in:
gresy pritty 8gresy pritty 8
Nectar Card Activation offers cash discounts for shopping or payments. Nectar Card Activate Card
Shri RajShri Raj
By using Salesforce Theme you should be able to tell
Shri RajShri Raj

Use these variables to identify the CSS used to render Salesforce web pages to a user. Both variables return one of the following values.
Valid values include:
Theme1—Obsolete Salesforce theme
Theme2—Salesforce Classic 2005 user interface theme
Theme3—Salesforce Classic 2010 user interface theme
Theme4d—Modern “Lightning Experience” Salesforce theme
Theme4t—Salesforce mobile app theme
Theme4u—Lightning Console theme
PortalDefault—Salesforce Customer Portal theme that applies to Customer Portals only and not to Experience Builder sites
Webstore—AppExchange theme


    <apex:pageBlock title="My Content" rendered="{!$User.UITheme == 'Theme2'}">
        // this is the old theme...

    <apex:pageBlock title="My Content" rendered="{!$User.UITheme == 'Theme3'}">
       // this is the classic theme ...

It should also be noted that there are some Salesforce bugs that cause the User.UITheme to return Theme3 when actually in Lightning. If that occurs you can use the UserPreferencesLightningExperiencePreferred on the User: 

List<User> users = [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id = :UserInfo.getUserId() LIMIT 1];
        Boolean userInLightning =users[0].UserPreferencesLightningExperiencePreferred;