+ Start a Discussion
uHaveOptionsuHaveOptions 

"OutputField" link in visualforce page issue. Open a "NEW" tab or


I have a visualforce page that is a lookup field value.  Works great and blends with the visualforce page.  

VF Field:
User-added image

VF Code:

<apex:pageBlockSectionItem>
<apex:outputLabel value="Relationship" for="Proposal__c.Relationship__c" style="font-weight:bold"/>
<apex:outputField value="{!Proposal__c.Relationship__c}" id="Proposal"/>
</apex:pageBlockSectionItem>


The problem I'm having is when I click on the link it opens inside that iFrame.  How can I solve the issue without using a Outputlink? And let it load a new page or a new tab.  I can use an output link because I need ti be able to modify that field data.

Error:
User-added image

Thanks you guys

DeepthiDeepthi (Salesforce Developers) 
Hi Jon,

You can work around using the commandLink. Please check the below link that explains with an example.

http://blog.jeffdouglas.com/2010/03/03/passing-parameters-with-a-commandlink/

Best Regards,
Deepthi
Mahesh DMahesh D
Hi Jon,

I don't think it is possible with a standard visualforce.
One workaround is to catch the click event on all anchor (a) tags that are wrapped with an element with a certain css class and "redirect" the link target to the new window/tab. For example:

 
<script>
    jQuery(document).ready(function() {
        jQuery('.openInPopup a').click(function(event) {
            event.preventDefault();
            window.open(jQuery(this).attr('href'));
        });
    });    
</script>

<apex:outputPanel layout="block" styleClass="openInPopup">
    <apex:pageBlock mode="edit">
        <apex:pageBlockSection>
            <apex:outputField value="{!a.CreatedById}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:outputPanel>

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

Please do let me know if it helps you.

Regards,
Mahesh