In SharePoint 2007 (WSS 3.0), you can put any URLs in the Links List. But when you click any of these links, they will be opened in the same browser window instead of in a new window.
I checked the Internet, and found a couple of ways to open the links list in a new window. The first one was the simplest one as I am concerned. I implemented and it worked for me.
Prepare a javascript script block to loop all links in the SharePoint, skip all internal links and Javascript links, and then set the target attribute value to “_blank” for any external domain links.
<script>
var thisDomain = window.location.hostname;
var theLinks = document.links;
for (i=0; i < theLinks.length; i++) {
var thisLink = theLinks(i);
if (thisLink.href.indexOf(thisDomain) == -1 && thisLink.href.indexOf(“javascript”) == -1) {
thisLink.target = “_blank”;
//alert(thisLink);
}
}
</script>
You can create a new Content Editor Webpart, and paste the Javascript above into it. Just make sure this Javascript only runs after all page elements load.
Or, just like I did I put the Javascript in the customized masterpage from SharePoint designer. It was pasted right before the </body> tag.
Method 2, Adding “OpenInNewWindow” option to SharePoint Links lists.
As Andrew Connell posted on his blog, you can make a few modification to add a new field to each link that allows contributors to specify if links should be opened in a new windows or not. The figure below is what the contributors will see when they add a new link.
I did not try this method, if you would like to try and want more detail information, please refer to Andrew’s post.
Method #3: Changing Links List In SharePoint 2007 To Open In New Browser Window by updating schema.xml file.
As marker126 indicated:
First, open the schema file for the links list feature. In my case, it was located at:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\LinksList\Links\schema.xml
In this file there should be two instances of the following:
<Column Name="URL" HTMLEncode="TRUE" /><HTML><![CDATA[">]]></HTML>Replace them both with this:
<Column Name="URL" HTMLEncode="TRUE" /><HTML><![CDATA[" target="_blank">]]></HTML>Then restart IIS (or just the application’s worker process), and now all the links in your links lists should open a new browser window!
I did not try this one either, since I do not like to change SharePoint core files which will be overwritten after a new update.
Method #4: Convert the links list to Data View and update the link properties.
You have to do this in SharePoint designer.
- Open the page with the links list web part. And right click the Links List web part.
- Select the option of “Convert to XSLT Data View” from the context menu.
- After the list has been converted, then select the URL field of the link item. And right click, select Properties, and set the option to Open in a new Window.
Hope one of these methods will work for you. Happy SharePointing.
Tags: Javascript, SharePoint, SharePoint Designer
Great post. Thanks for all the options/methods. I will be able to use two of these right away.
[Reply]
I am not a javascript coder so have a question about method one. I added a CEWB below my link list. I copied the code as is into the CEWB. The behavior of the links does not change. I have a link to google and it still displays in the same window. Do I need to modify “thisDomain” or “hostname” to reflect my site’s domain or hostname? Thanks.
[Reply]
Thanks for the Information, thanks for your fine Article. Also check these nice Blog. estate agents belfast
[Reply]