Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

Thanks!

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 at 8:40
    
@MohithKumar added an example –  nickforce Mar 17 at 9:03
add comment

1 Answer 1

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:

<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>
share|improve this answer
add comment

Your Answer

 
discard

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.