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


Should be able to add a target attribute:-

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

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();" />
| improve this answer | |

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.