I want to open my Vf page on new tab please guide me what i need to do to get the process done my code :

 public PageReference totalbookedClick(){
     date myDate = date.today();
    integer thisyear = myDate.year();
     PageReference pageRef = new PageReference('/apex/TotalBookedPage?contact= {!'+cntMap.keyset()+'}&End_Date={!'+thisyear+'}&Start_Date={!'+thisyear+'}');
     return pageRef ;

Vf page

           <apex:form > 
           <apex:commandLink value="{!LB}" action="{!totalbookedClick}" />

please guide me what else need to do get it working

2 Answers 2


Should be able to add a target attribute:-

<apex:commandLink value="{!LB}" action="{!totalbookedClick}" target="_blank"/>

To do this using JS directly in the VF page

 function openInNewTab(){
     var date = new Date();
     var thisyear = date.getFullYear();
     var url = '/apex/TotalBookedPage?contact={!cntMap.keyset()}&End_Date=' + thisyear + '&Start_Date=' + thisyear;
 <apex:commandLink value="{!LB}" onclick="openInNewTab();" />

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .