I am having an application in which I have added one Tab in it also it has a default Home Tab.

Now I need to open up another visualforce page on a button click.

I have used PageReference here :

    public PageReference GoToMasterPage(){
        PageReference pr = new PageReference('/apex/MySecondPage');
        return pr;

whenever it gets executed it opens up correct VF page but, the focus always shifts to Home Tab which was present by default.

I do not want the focus to shift to the Home tab or any other tab. I it need to focus on the currently selected tab itself.

How can I achieve this?

1 Answer 1


If the new tab which you created is a visual-force tab than add tabStyle attribute in page tag in your MySecondPage page. So the page code would be like :

<apex: page tabStyle="TabName__tab">
   <!---page code-->

If the tab related to custom object then:

<apex:page tabstyle="CustomObject__c">
  <!---page code-->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.