Wednesday, November 10, 2010

Make Links Open In New Window

Well we know, when you add a link to your SharePoint navigation or in a Summary Link Web Part, it gives you the option to "Open link in new window" But when comes to a standard Links list, doesn't give you this option.

Here is The Script to open the link in a new window: (Content Editor web part, or even added to your master page.)

<script language="javascript" type="text/javascript" >

function MakeLinksOpenInNewWindow(){

var tbl = document.getElementsByTagName('table');
for(var i = 0; i < tbl.length; i++)
{
if(tbl[i].getAttribute("summary") == "Links Use the Links list for links to Web pages that your team members will find interesting or useful.")
{
var anc = tbl[i].getElementsByTagName('a');
for(var j = 0; j < anc.length; j++)
{
anc[j].setAttribute('target', '_blank');
}
}
}

}

_spBodyOnLoadFunctionNames.push("MakeLinksOpenInNewWindow");
</script >

Note: You can modify default Summary attribute by editing Links >> List Settings >> General Settings {Title, description and navigation} Description field of that Links list.
Also note that Summary attribute constructed with combination of Name + Description of the List

1 comment:

Unknown said...


Thanks! But simple and easiest solution is: Create a Site column of "Hyperlink with formatting and constraints for publishing" type and add it in your list, which enables you to specify "Open in New Window" Option!

There are few more possible solutions, including JavaScript, JQuery, SharePoint Designer, List Schema Edit to make SharePoint Link list open in new window at SharePointDiary.com -

SharePoint Link list: Open in a New Window