Changing Links List In SharePoint 2007 To Open In New Browser Window

I was recently looking for the easiest way to modify the links list in SharePoint 2007 to open the links in a new window.  In my case, every link in a links list points to an external site, so they should all be opening a new browser window.
 
There were a couple custom features I found, but most required modifying (or replacing) the existing links lists, something that I did not want to do.  Anyway, here's how to make the change (note:  I modified the original files, this probably isn't a best practice, and the changes could be lost by updates from Microsoft).
 
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!

38 Comments

  • Hi,

    Please forgive my little rant.

    -- begin rant
    The notion that links even to external sites "should open in a new window" is not the view of the w3c or the accessibility community.

    The user should always be in control therefore you really shouldn't open links in new windows. The problem is through historical bad practices some users seem to expect this. I think we need to educate our users about the basics of using web browsers. Every major browser allows the user to open in a new window or tab by right clicking the link. The user should be empowered to control when new windows open for themselves and the expected behavior should be that clicking a link does not open a new window.

    -- end rant :-)

    With your example, the page will not be valid XHTML because the target attribute was deprecated. However for those who really want to open windows there is a way to do it and still pass the w3c xhtml validator. Instead of putting the target in as you have it, this would do the same result and pass the validator:

    onclick="window.open(this.href,'_blank');return false;"

    Still, my 2 cents is its better not to open new windows just because its an external link.

    Cheers,

    Joe

  • Hey Joe, thanks for your input!

    I agree with you 100%. Funny that you should say something, because when my manager originally requested this feature, my response was "can't the user just hold down SHIFT?" But, when it comes down to it I don't have the final say, such is life.

    I like your suggestion for setting the onclick event handler, I'll have to try it out.

  • Will this affect all out of the box links lists? What if you just want this to affect an individual links list?

    --S

  • S:

    This will affect all OOTB link lists. To affect an individual links list you'll need to create a custom feature. Good luck!

  • Hi Joe,

    So what would be the full syntax of the new code?

    Thanks!

  • as one poster said cant the user hold down the shift key. that would be too easy and egos would not be fed.

  • I agree with the "shift" and "right click" options however I agree with the author as well....I am maintaining Intranet sites for my company and the end users aren't exactly all computer savy so I am forced to come up with a way have a new window open as well due to requests by my management.

  • I feel that there should be a checkbox on the properties page for links to indicate that the page should open in a new window. I consider this to be a missing feature.

  • i applied your action then the same issue (the same window) i reset IIS

  • Yes, my users are not savy AT ALL. Asking them to Shift Click or Right Click is asking too much. Thanks for the help though...

  • Sorry, but I disagree entirely with Joe's rant. External links should ALWAYS open in a new window. Otherwise the user has to resort to the browser's back button to get back to the site, which is very very messy. In my opinion, opening images, pdfs or external web pages in the same window is ridiculous.

  • Totally agree with Bryan. I have several external links. My users aren't savy either. In the end, the customer must get what they want.

  • Excellent tip. It might not meet all the best practices, but well this is an intranet and I am going to do it the way I want. Worked like a charm. Thanks.

  • Thanks a lot!!!!!!!!!!

  • I have an NO CODE OPTION...I haven't fully tested this in all areas but it's working for me so far.

    In the Issue Tracking list there's a column type called "Hyperlink with formatting and constraints for publishing". This column type allows you to define whether the link will open in the site or "in new window".

    1. Create a new List using Issue Tracking.
    2. Create a column using type "Hyperlink with formatting and constraints...."
    3. Remove all the other columns (Title and Category can't be removed)
    4. Change the Title column..in Default value put an "x" or something else.
    5. Create a View showing only the Link column.

    Now you can add a webpart anywhere on your site using this list and View.

    I'm using SP2008 with MOSS 3...I'm sure that makes a difference.

  • Thanks for this information - this did the trick!

  • I totally agree with the author too. If you don't open an external link in a new window it is difficult to 'unwind' their way back to the orignal site - especially if they have clicked several links on the external site. Usability suffers and in this case telling the users that you followed some standard will fall on deaf ears. If the standard is as Joe explained, it should be changed.

  • Thanks a lot!!! You made my day!

  • I disagree with making the links automatically open the link an a new window. And totally agree with the standard. The user already has the ability to open a link in a new window or tab by right clicking on the link and selecting new window or tab from the shortcut menu. So usability doesn't suffer, but it does force users to know this small bit of information. And the standard is set this way because of usability AND ACCESSIBILITY. (A point every other commenter above me missed.) Screen readers read through the code to tell vision impaired users what is on the page. So reading target="_blank" really makes a lot of extra junk for vision impaired users to sort through. So my feeling is if you have no impairment and you are too lazy to do a right button click, blindfold yourself, hook yourself up to a screen reader AND try answering customer service calls with the customer talking in one ear and the screen reader reading information back to you in the other. Then navigate the page. On external sites, you should follow the standard, you do NOT know who your users are--only the demographic your company typically appeals to. For Intranet sites you should follow the majority of standards because you only know who your users are that day, not in the future. My place of employment that provides customer service has had vision impaired employees working customer service. The ADA requires reasonable accommodation--and considering this is the standard practice, it is a reasonable accommodation. Wouldn't it really suck if you had to go in after the fact to change all of your links and THEN retrain the rest of your workforce? Maybe your IS department needs to step out of IS and take a look at other departments, namely HR and inform them of the issue. Then maybe they can tell you if you will be changing all of your code down the road.

  • the "shift" "rt click" is not working for the MY Links to open in a new window... is there a setting somewhere that turned that off?

  • Hi guys

    I used this

    javascript:void window.open('mypage.aspx?','_blank');

    It works!

  • Joe,
    You need to live in the real world! You have obviously never designed real websites for the real world, it's so easy to jump on the W3C bandwagon and quote their rubbish! Just checked out you site, quite a few external pages open in new windows. Hypocrite Alert!!!

  • Everyone,

    I just saw Matt's "NO CODE OPTION" and was able to make it work in any List/Library on a site collection using the "Site Columns". Here's how:

    Go to the Site Settings,
    Galleries,
    Site Columns,
    Create (button at the top left),
    Enter a Column Name,
    Check the box - Hyperlink with formatting and constraints for publishing,
    Hit OK

    Now Go to your List/Library,
    Go to Settings,
    Do "add from existing site column",
    Locate your recently created "site column" from the group you selected previously,
    Select it, Click Add and OK,
    Now you have a new URL column that allows you to make the hyperlink open in a new window.

    This looks just like the CEWP hyperlink field.

  • One Follow up...
    Publishing Feature will need Activated on the Site Collection to use the above method.

  • Rob, you are the champion! It's the ultimate solution due to it's simplicity. I just used your solution on our companies internal portal site and deployed it. Cheers and hailings are still echoing through the building. Every END-USER department (and we have hundreds) adores it.
    And not compliant to W3C standards? They couldn't care less!

  • hi,

    I have a slf file in links list. When user click on this file, my website will display information of this file in silverlight. How can i do that ? Thanks

  • Nice work Rob, your fix solved my problem

  • The client user is always right! So I believe you are wrong. I’ll give you one good reason why you should have your outside links opened in a new page or Doc's, it is based on the fact that almost all websites are a form of marketing. If you let your client click on a link within your web site that takes them away from your logo your sales information you are the one missing out. If the client finds navigating your site upsetting they may not visit you again, they may visit your neighbour instead. You are dealing with mums and dads, some of whom don’t even know how to cut and paste. Speaking for my-self, when I open a PDF file within a website and I have finished reading it I automatically close it, I find it annoying if it was not opened in a new window.

  • I am on SharePoint 2010 and tried this approach by modifying the schema.xml file and then restarting IIS and the effect is not taking place. Are there any other steps I am missing? Thanks.

  • This doesn't work for me either?

  • If you have links to external sites from an intranet it is obvious they should open in a new window. Its all about convenience for the end user, who are rarely techy and tbh I found myself on this thread looking for a solution to this issue because imho its an oversight.

  • how to get the report of number of external link clicks

  • Thanks Matt! The Issue Tracking list was exactly what I needed.

    And for those doubting the appropriateness of this solution, in my case some of my links lead to another Intranet application that loads a new window and closes the one it is loaded in. The user cannot click back to return to the original site because the original window is closed. So while this may not be W3C approved, by opening in a new window I'm allowing our users to keep using the site they started on instead of getting frustrated when they need to go back to it and find they have to start over.

  • I'm looking for this hack for SharePoint 2010 too ...

  • Changing links list in sharepoint 2007 to open in new browser window.. Very nice :)

  • Does anyone know how to open a calendar item in a new browser window when clicked?

  • Works great! Thanks :)

  • Joe sounds like a butt.

Comments have been disabled for this content.