function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Justin Epistola 1Justin Epistola 1 

Visualforce open in a new tab

Hi, I am an Administrator who is starting out in Visualforce and just needs help with this; 

I created a visualforce page that shows the related list of a custom object; Here is what I used; 

<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}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

The issue with this is - When I am clicking on Lookup values (Accounts related and Account plan name) they are opening the same component that I created and is not opening a new tab. 

Question: What Can i do to make any lookup clicks open in a new tab?
SandhyaSandhya (Salesforce Developers) 
Hi,

You can try with below code.
 
<apex:inputField value="{t.owner}" id="ownerId"/>

<script>
  document.getElementById('{!$Component.ownerId}').target = "_blank";
</script>

Also refer below link.

https://salesforce.stackexchange.com/questions/30253/control-the-target-window-of-outputfield-if-a-link
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya