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

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

If you 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.



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

Actions Required to Resolve the "How-To"

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

JQuery
The original forum thread
JQuery .each

Leave a Comment
  • Please add 7 and 3 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 1 (5 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
Page 1 of 1 (7 items)