Here is a solution how to find if page has been opened in service console.
It can be also used to pass any parameters from javascript to apex controller.

Visualforce:

<apex:page controller="MyController" sidebar="false" docType="html-5.0">
    <apex:includeScript value="/soap/ajax/34.0/connection.js"/>
    <apex:includeScript value="/support/console/34.0/integration.js"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery, '/jquery.min.js')}" />

    <script>   
        $j = jQuery.noConflict();
        $j(document).ready(function() {  
            setConsoleStatus();
        });
        // Set cosole value in hidden field
        function setConsoleStatus() {
            inConsole = sforce.console.isInConsole();
            $j('[id*="ConsoleStatus"]').val(inConsole); 
        }      
    </script>
        
    <apex:form >
        <apex:inputHidden id="ConsoleStatus" value="{!pageInConsole}" />
        <apex:pageBlock id="theBlock" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton value="TestConsole" action="{!inConsole}" rendered="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>    
</apex:page>

Apex:

public with sharing class MyController {
    public Boolean pageInConsole {get; set;}

    public pageReference inConsole() {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'In console value:' + pageInConsole));
        return null;
    }
}

 

   
© Paweł Woźniak