I am an Administrator starting out in VF pages. I created a simple page that shows related list information; Here is the code;

<apex:page standardController="Account_Plans__c">
<apex:pageBlock >
<apex:pageBlockTable value="{!Account_Plans__c.Key_Contact_and_Objective__r}" var="Key_Contact_and_Objective">
 <apex:column headervalue="Key Contact and Objective"><apex:outputLink value="/{!Key_Contact_and_Objective.id}">{!Key_Contact_and_Objective.Name}</apex:outputLink></apex:column>
  <apex:column value="{!Key_Contact_and_Objective.Key_Contact_Name__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Contact_Title__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Hugrank__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Hugrank_Score_Increase__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Pardot_Score__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Pardot_Score_Increased__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Pardot_score_date_updated__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Relationship_Lead__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.What_they_care_about__c}"/>
  <apex:column value="{!Key_Contact_and_Objective.Role__c}"/>

It is working alright but when anything lookup related is clicked it opens in the same page and same space it does not open in a new tab.

Is there anything I can do to make it open in a new tab instead of opening in the small vf space assigned in the page?

3 Answers 3


If you mean your Tag you can use the target=”_blank” attribute to open a new tab on click

  • Thank you! It worked. I added Target=_blank" and its opening in a new tab now rather than opening in the same frame! Commented Aug 28, 2018 at 15:52
  • I'm confused why someone down voted this answer. Not only does it answer the specific question asked, but it's correct. Commented Aug 28, 2018 at 16:08

No luck here.You have to write some visualforce for that:

<apex:column headerValue="{!$ObjectType.CustomObject__c.fields.FieldLookup__c.label}">
    <a href="/{!CustomObject__c.FieldLookup__r.Id}" target="_blank">
        <apex:outputText value="{!CustomObject__c.FieldLookup__r.Name}"/>

So, you need to set the target attribute of each link on the page. Problem is, you aren't creating the links yourself - you can't be sure which columns will and won't be a link at runtime. Usually for cases like this (since you can't set attributes via css) you have to add a little javascript to the bottom of the page (so that the code runs after everything renders) to make some modifications.

document.querySelectorAll('a').forEach( (v) => v.setAttribute('target', '_blank'));

This one-liner will set the target attribute for ALL links on the page to _blank. You might want to localize it a little, maybe by adding an id to your pageBlockTable and just looking inside that (say, #myTable a for the selector).

You must log in to answer this question.

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