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
Qin LuQin Lu 

how to make output link work for both drill down and open a new tab

I have a visual force page embedded in Contact detail page layout. I have a output link to drill down to detail custom object page. I have the following in my page, and it drill down correctly to detail custom object page, but it doesn't work when do right click Open in New Tab, I got 
URL No Longer Exists error

<apex:outputLink onClick="window.top.location.href = '{!redirectUrl}';">{!fa[field]}
</apex:outputLink>

How to make the output link work for both drill down in the same window as well as Open in New Tab?

Thanks
Best Answer chosen by Qin Lu
bob_buzzardbob_buzzard
Open in new tab will try to open the URL in the anchor tag generated from the output link, but you haven't provided one.  You'll need to add the target URL and make the onclick handler return false so that you don't get a race condition. The following should do the trick:

<apex:outputLink value="{!redirectUrl}" onClick="window.top.location.href = '{!redirectUrl}'; return false;">{!fa[field]}
</apex:outputLink>