Links in a SharePoint document library open in a new window

October 11th, 2006 | Categories: Personal

To make links from SharePoint lists, document libraries, etc. open in new window is usually easy with FrontPage 2003 or SharePoint Designer and inserting a Data View.

But this caused problems. In some cases when you’re including xslt data view you can have trouble saving site like template. What worked for me is to put a little script just before the </body> tag, that changed the target window of links inside of document library. The script is based on WSS CSS recognition so you can use it also for other cases.

Below is the code for the script:

<script language="javascript" type="text/javascript"> i=0 while (document.links[i]) //check all document links  {    if (document.links[i].parentNode.className == "ms-vb2" || document.links[i].parentNode.className == "ms-vb" || document.links[i].parentNode.className == "ms-vb-icon") //if is inside of DL webpart, do it:    {     document.links[i].target='_blank'    }    i++  } </script>

  1. Jase
    August 13th, 2007 at 08:50
    Reply | Quote | #1

    Any ideas on how to get a link to open a new window in a datasheet view? I’ve tried everything, but to no avail! help

  2. Jase
    August 13th, 2007 at 08:51
    Reply | Quote | #2

    This is for SharePoint Portal Server 2003…