Adding "OpenInNewWindow" option to SharePoint Links lists

In this article, learn how to add a new field to each link in SharePoint sites that allows contributors to specify links should open in new windows or not.

I’d assume that almost any SharePoint admin/site owner has received a request by an end user or content owner that they want to specify if links in the Links list Web Part open in a new window or not. Usually there’s not much you can do. This recently came up again in the Mindsharp moderated Yahoo Group… and you’ll always see it in one of the SharePoint newsgroups. Many people have come up with their own solutions… some involving modifying JavaScript, others using hidden workarounds (like Todd’s Content Editor Web Part method).

With the abundance of requests for this, and with the need to do something with CAML which I’m very new to, I decided to create my own SharePoint list template by copying an existing site definition and modifying it for my own uses. I’ve documented the entire process in a two part article. The first part explains, briefly, how to create your own site definition (this can be skipped if you know what you’re doing). The second part deals with making changes to the SCHEMA.XML file for the Links list template. My approach is simple: add a new boolean field that “Open In New Window”, modify the existing default views, and add a new computed column which will render the link with target=”_blank” if the new field is checked. This new computed field is nice as you can elect not to use it in the default/custom views… you can use the original “URL” field which renders the anchor tag the same old way.

The article is compete with references to other related articles and downloads of all the files modified so you don’t have to do it yourself (or you can use them to follow along when you step throughout the article).

Keep in mind this method is great for new sites, but could cause issues if you decide to implement it in existing site definitions including the ones Microsoft provides OOTB or your own custom site definitions. This is also addressed in the article.

Let me know what you think! I’m interested in receiving some feedback on my method.

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment