Important notice

Please note that this blog is discontinued here. All the posts are also coppied to my new blog at http://boris.gomiunik.net.
Important: Due to large amount of comment spam further commenting has been disabled here. If you wish to send me a comment, plase look up the same post on my new blog and leave comment there. Thanks!

10/11/2006

Links in a SharePoint document library open in a new window

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>

2 comments:

Jason Jong said...

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

Jason Jong said...

This is for SharePoint Portal Server 2003...