Skip Ribbon Commands
Skip to main content
CW SharePoint Design > Blog > Posts > Open Link List links in New Window in SharePoint 2010
April 12
Open Link List links in New Window in SharePoint 2010

There have been big changes in SharePoint 2010 with the way list web parts are handled. Now instead of a Data View Web Part or a List View Web Part, we have something that is more or less a combination of the two, an XSLT List View Web Part, which I have seen referred to as XLV. This is certainly for the better, but it may leave some to wonder how to do simple tasks. One of the most common one needed is to have links open in new windows. This is really more of an issue in SharePoint Foundation than it is server, but the same holds true for both.

  1. Open your page in SharePoint Designer
  2. Click on the Web Part, by default you will see the XMLDefinition for this web part, but nothing that allows you to make changes such as having the link open in a new window.
  3. While the web part is selected look at the toolbar and select the Design Tab, located in the List View Tools
  4. Select Customize Entire View from the Customize XSLT menu
  5. Now locate <a onfocus="OnLink(this)" href="{$url}">, if you click next to a link you will get close, or just perform a search for the item
  6. Change this to be <a onfocus="OnLink(this)" href="javascript:void();" onclick="window.open('{$url}');">
  7. Save the file, clicking yes to any warnings that may show
  8. Test out the page, that's it

I have noticed that from time to time the save doesn't stick the first time around, so if it doesn't work try it again, just make sure to click Yes to the warnings and make sure the page was not already in edit mode in the browser before you made these changes as that could potentially overwrite the change you just made.

Cory

Comments

Excellent

I did a lot of searching for this solution. THANK YOU for explaining so well and simply.
 on 6/21/2011 9:17 AM

The best solution that i've seen !!!!

I recommend !!

Simply and quickly !!
 on 7/5/2011 1:21 AM

Works great!

Thanks for the post.
 on 7/6/2011 2:29 PM

An error

When i made these change, nothing changed ? Why ?
 on 7/7/2011 4:43 AM

RE: An Error

SharePoint Designer sometimes rejects the change, I have no real explanation as to why, still trying to figure that out, I am assuming its a bug with the software
cory@cwsharepointdesign.comNo presence information on 7/24/2011 3:51 PM

RE: RE An Error SOLUTION

If you choose to restore the entire display and you do another time the tuto its good !!
 on 7/25/2011 4:53 AM

RE: RE An Error SOLUTION

If you choose to restore the entire display and you do again the tuto its good !!
 on 7/25/2011 4:53 AM

Single Link

HI,

Thanks for the post, its nice and works quite well. I have a requirement though - to only open certain links (NOT ALL) from a links list. For example: some links are to other areas in SharePoint and some are external sites (non SP) which we want to open in a new browser/tab. Is it possible?
Cheers,
Sabs
 on 6/18/2012 8:38 AM