Making links open in a different window via jQuery

May 9th, 2012 | Posted by Marijn in code | jquery / javascript | sharepoint | sharepoint 2010

A common requirement I get when editing SharePoint search pages is making the links open in a different window/tab.
You could ofcourse go off and edit the xsl (which is quite easy by the way), but you could also look at jQuery to save the day once more.

Just add a content editor webpart to the results page, link to the jquery library and add this line:


What this code does is add an attribute to all ‘a’ elements, the links. The attribute here is that it should open in a new window.

This code is not limited to the results page ofcourse, you could use it anywhere you want, even in non-SharePoint sites.

You can follow any responses to this entry through the RSS 2.0 Responses are currently closed, but you can trackback.

%d bloggers like this: