Much to my disappointment, Links list in MOSS 2007 still does not have the feature to set whether the link should open a new browser window when the user clicks on the URL value. There’s quite a handful of blogs writing how to do this. Here’s my take on how I go about doing it.
1. Create a new content type, inheriting from Links list. I’ll call it Custom Links
2. Add a new site column to the Custom Links content type call “Open In New Browser” of type Boolean (Yes/No). This column will indicate whether the hyperlink should open in a new browser window or on existing browser window.
3. Add some hyperlinks into the list. This will help visualization during modification in SharePoint designer.
4. For my case, my users will only view Custom Links using several custom views. So I use the SharePoint Designer approach. Locate and open the view pages in SharePoint Designer.
5. Right-click on the Custom Lists web part and select “Convert To XSLT Data View”.
6. Locate the URL field by clicking on the URL value on screen.
7. Referring to the screenshot, immediately after the xsl otherwise tag, replace the whole chunk of code starting from the Anchor tag with the following:
<xsl:choose>
<xsl:when test="@Open_x0020_In_x0020_New_x0020_Br='1'">
<A onfocus="OnLink(this)" HREF="{substring-before(@URL, ', ')}" target="_blank">
lt;xsl:choose>
<xsl:when test="substring-after(@URL, ', ')=''"><xsl:value-of disable-output-escaping="no" select="substring-before(@URL, ', ')" /></xsl:when>
<xsl:otherwise><xsl:value-of select="substring-after(@URL, ', ')" /></xsl:otherwise>
</xsl:choose>
</A>
</xsl:when>
<xsl:otherwise>
<A onfocus="OnLink(this)" HREF="{substring-before(@URL, ', ')}">
<xsl:choose>
<xsl:when test="substring-after(@URL, ', ')=''"><xsl:value-of disable-output-escaping="no" select="substring-before(@URL, ', ')" /></xsl:when>
<xsl:otherwise><xsl:value-of select="substring-after(@URL, ', ')" /></xsl:otherwise>
</xsl:choose>
</A>
</xsl:otherwise>
</xsl:choose>
8. Optional: Somehow the URL column became not sortable and has a funny formatting. Easily fixed by making it sortable again by changing the sortable value to 1.
Additional references that uses different methods below:
http://wss.collutions.com/Lists/FAQ/DispForm.aspx?ID=254
http://www.andrewconnell.com/blog/articles/SharepointLinksListOpenInNewWindow.aspx
http://weblogs.asp.net/bsimser/archive/2005/02/07/368326.aspx