Share via


SharePoint 2010: Change a Lookup Hyperlink to Open in the Same Window

Ifyou create a lookup column in a SharePoint list, the link on the DataView will open the linked item in a modal popup. This page explains how to open it in a new page.

This article comes from this forum thread: SharePoint 2010 - Change lookup hyperlink to open in same window.

We will use a little bit of JavaScript, which will change the rendering code of the DataView.

Prerequisites

1. SharePoint 2010 (Server or Foundation)
2. SharePoint Designer 2010
3. A created list with a lookup column, and at least one item in this list
4. 5 minutes to do this

Steps

1. Connect to the site within the list you created with the SharePoint Designer.
2. Go to "Lists" and select the list you created (with the lookup column)
3. On the right hand corner, you'll see the views of the list. Open one of them by right-clicking and select "Edit File in Advanced Mode"
4. Once your page is open, be sure you are displaying the code of the page, by clicking on "Code" at the bottom of the window.
5. Prepare jQuery (if it's not already added). Keep in mind that loading jQuery two times on the same page could create some bugs.

To add and load jQuery:

- Download jQuery on the official website : http://jquery.com/

  • Upload it in a folder or in a document Library
  • Copy and paste its URL to the notepad

6. Near the end of the page, find this piece of code :

<style type="text/css">
.ms-bodyareaframe {
 padding: 0px;
}
</style>

7. Insert right after that code:

<script type="text/javascript" src="the/path/you/paste/jquery.js"></script>
<script type="text/javascript">
 $(document).ready(function() {
   $("td[class='ms-vb2'] a").each(function() {
     $(this).attr("onclick","");
    });
 });
</script>

8. Save, reload, and enjoy !
 


References