I was searching around for information on how I could enhance my SharePoint search results and came across this blog with some tips. The tip about opening links in new windows instead of the same window was a great idea but I couldn’t use the same tips since it was for SPS 2003. I wanted to be able to open links in new windows since I noticed a lot of users often times were searching for say PDF’s and then they would accidentally close the browser instead of hitting the back button. Big annoyance for them.

So I was snooping around the Search Core Results Web Part’s XSL Editor to see if I could edit the XSL to open links in new windows instead. It’s actually pretty easy, here are the steps:

1. Go to http://portal/searchcenter/pages/results.aspx

2. Modify Shared Web Part for the Search Core Results WebPart

3. Click on the XSL Editor Button

4. I’d suggest copying the contents of the pop up into notepad/wordpad to do your editing.

5. Search for the following lines:

<span class=”srch-Icon”>
<a href=”{$url}” id=”{concat(‘CSR_IMG_’,$id)}” title=”{$url}”>

______________________________________________

<span class=”srch-Title”>
<a href=”{$url}” id=”{concat(‘CSR_’,$id)}” title=”{$url}”>

____________________________________________________

<xsl:choose>
<xsl:when test=”$IsThisListScope = ‘True’ and contentclass[. = 'STS_ListItem_PictureLibrary'] and picturethumbnailurl[. != '']“>
<div style=”padding-top: 2px; padding-bottom: 2px;”>
<a href=”{$url}” id=”{concat(‘CSR_P’,$id)}” title=”{title}”>

__________________________________________

<span class=”srch-URL”>
<a href=”{$url}” id=”{concat(‘CSR_U_’,$id)}” title=”{$url}” dir=”ltr”>

____________________________________________

6. At the ends of each of the <a href= > tags, you’ll want to add on target=”_blank”

For example to make the link attached to the document icon open in a new window, the full tag would be like this:

<span class=”srch-Icon”>
<a href=”{$url}” id=”{concat(‘CSR_IMG_’,$id)}” title=”{$url}” target=”_blank”>

Using the same XSL Editor you can also manipulate how your search results are displayed and even include custom content types if you wanted to!

21 Responses to “How to make MOSS 2007 search results open in new window”

  1. Antony Henry Says:

    Good one….useful tip….I’m wondering why this didn’t strike me in the first place

  2. Biswajit Says:

    This a nice article. But my requirement is, clicking on the document link in Search Result page should open documents in respective application instead of Browser Window. So that user can edit the doc and save it to document source. Just like what is happened in Document library.

    Please help me.

    Thanks

  3. Thomas Says:

    Hey Biswajit, did you find a solution for your problem? I’m trying to do the same, but can’t find a way.

  4. Dawn Says:

    I can’t get this to work. I’ve tried both “_target” & “_new” in all four locations.

  5. sharada Says:

    Hi,

    I tried putting in target =”_new” and it is not working, we cannot touch the 12 hive directory and need to do this setting at a XSLT level, please help

  6. Henry Says:

    For those having difficulties – haven’t tested this but sometimes the blog styling will use fancy quotes and when you copy/paste, it doesn’t convert to the proper basic quote/unicode character. Try taking out the quotes and typing them back in manually. :)

  7. PrashanthSpark Says:

    I want to change CSR_IMG_ icon for folder instead of displaying IE image…

    any one has tried this idea!

    public void PreRender_Handler(object sender, System.EventArgs e)
    {
    CoreResultsWebPart coreResults = (CoreResultsWebPart)sender;
    string s = “(.*?)“;
    string repl=”$0$1“;
    Regex ex=new Regex(s,RegexOptions.Multiline|RegexOptions.IgnoreCase|RegexOptions.RightToLeft);
    string searchResultsTxt = ((Literal)(coreResults.Controls[0])).Text;
    string replaced= ex.Replace(searchResultsTxt, repl);
    ((Literal)(coreResults.Controls[0])).Text = replaced;
    }

  8. PrashanthSpark Says:

    This is the XML tag

  9. Bob Says:

    To Dawn: It should be _blank, as in target=”_blank”

  10. uxjahd Says:

    harb45 test test544343

  11. hvjpjh Says:

    yugygu6756 tyu hffdrtd y guyg ug

  12. z6bp4h Says:

    gfg5454 hghj

  13. lqyyx0 Says:

    hjhggg6642 test test

  14. 8rj612 Says:

    ghhhh5432 gfhg ghfgffff

  15. 9yfoix Says:

    yyy8980yy ttttt rrrrr

  16. kbqwnp Says:

    hhhk56567 fghff gffgfgggg

  17. f8l6r1 Says:

    jjjjj67566 fgfgf sdssess er rtd


  18. I admit, I have not been on this webpage in a long time… however it was another joy to see It is such an important topic and ignored by so many, even
    professionals. I thank you to help making people more aware of possible issues.
    Great stuff as usual….

  19. Jim Heidecker Says:

    This is great for regular search results page. Do you have a solution for a search scope such as ‘This Site’ where the results are returned on the page:
    http://…/_layouts/OSSSearchResults.aspx

    Thanks much!

  20. Jackson Says:

    There are many landmarks in the world people climb. Have you ever climbed one and if yes, which one(s)?


Leave a Reply