Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any known workarounds for controlling the target window when clicking a link if the link was generated from an outputfield?

I didn't see anything mentioned in the docs on this.. but it would be nice so I don't have to perform extra queries to display the name of an OwnerId for example.



<apex:outputLink value="/{!t.OwnerId}" target="_parent">{!ownerNameString}</apex:outputLink>

Is it possible to specify a target attribute like in the outputLink above, but instead for an outputField when it will be rendered as a link?

share|improve this question
Could you please elaborate more here ?Can you post some code you have used – Mohith Shrivastava Mar 17 '14 at 8:40
@MohithKumar added an example – nickforce Mar 17 '14 at 9:03
up vote 2 down vote accepted

I don't think it is possible with a standard visualforce.
One workaround is to catch the click event on all 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:

    jQuery(document).ready(function() {
        jQuery('.openInPopup a').click(function(event) {

<apex:outputPanel layout="block" styleClass="openInPopup">
    <apex:pageBlock mode="edit">
            <apex:outputField value="{!a.CreatedById}"/>
share|improve this answer

An easier solution that doesn't involve jQuery is to get the field and just add the target attribute to it. Something along the lines of:

<apex:inputField value="{t.owner}" id="ownerId"/>

  document.getElementById('{!$Component.ownerId}').target = "_blank";
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.