Apr/28
2010

Let me first start by saying the script we're providing is adapted from script posted by Ricky Spears (http://sharepointsolutions.blogspot.com/2007/09/make-selected-links-in-links-list-open.html)

OOB Sharepoint Link Lists do not provide you the option to have a links open in a new window. The following steps and script will allow for such functionality.

Steps:

  1. Add a Content Editor Web Part (CEWP) to the page where the linked list web part is located.
  2. Select Modify Shared Web Part on the newly added CEWP
  3. Now click the "Source Editor..." button that is now present and insert the following script (Note, you can choose to hide the title and chrome of this web part so that it is, in-effect, hidden from the end-user):
    <script language="JavaScript">
    _spBodyOnLoadFunctionNames.push("rewriteLinks");
            
    function rewriteLinks() {
      //create an array to store all
      var anchors = document.getElementsByTagName("a");
                
      //loop through the array
      for (var x=0; x<anchors.length; x++) {
        //check to see if the current anchor element contain #openinnewwindow
        if (anchors[x].outerHTML.indexOf('#openinnewwindow')>0) {
          //add the [target] attribute and rewrite the [href] attribute
          anchors[x].target = "_blank";
          anchors[x].href = anchors[x].href.replace(/#openinnewwindow/,'');
        }
      }
    }
    </script>
    
  4. Next, add a new link to the linked list and append the following text to the end of your URL "#openinnewwindow" (e.g. http://www.google.com#openinnewwindow ).
  5. Finally, click on your link and it will now open in a new window.

3 comments
Comment from: Stefan [Visitor]
Stefanthat's perfect! thank you very much. It works fine and it was pretty easy to "install" :)
05/21/10 @ 14:16
Comment from: jason [Visitor]
jasonthanks for the updated script!
06/07/10 @ 15:42
Comment from: Steve [Visitor]
SteveIt works! Thanks very much. This is very helpful.
06/28/10 @ 12:36

This post has 1 feedback awaiting moderation...

Leave a comment

Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)