How to make MOSS 2007 search results open in new window
October 27, 2007
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!



November 23, 2007 at 2:08 am
Good one….useful tip….I’m wondering why this didn’t strike me in the first place
March 20, 2008 at 2:43 am
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
April 9, 2008 at 11:54 pm
Hey Biswajit, did you find a solution for your problem? I’m trying to do the same, but can’t find a way.
August 28, 2008 at 9:20 am
I can’t get this to work. I’ve tried both “_target” & “_new” in all four locations.
October 29, 2008 at 1:26 pm
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
November 2, 2008 at 1:21 pm
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.
December 8, 2008 at 12:56 am
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;
}
December 8, 2008 at 12:56 am
This is the XML tag
February 18, 2009 at 8:05 am
To Dawn: It should be _blank, as in target=”_blank”
May 13, 2009 at 3:03 pm
harb45 test test544343
May 13, 2009 at 3:55 pm
yugygu6756 tyu hffdrtd y guyg ug
June 8, 2009 at 9:23 pm
gfg5454 hghj
June 8, 2009 at 9:47 pm
hjhggg6642 test test
June 10, 2009 at 1:18 pm
ghhhh5432 gfhg ghfgffff
June 12, 2009 at 6:04 am
yyy8980yy ttttt rrrrr
June 12, 2009 at 6:21 am
hhhk56567 fghff gffgfgggg
June 12, 2009 at 7:12 am
jjjjj67566 fgfgf sdssess er rtd
July 7, 2009 at 9:33 pm
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….
September 17, 2009 at 8:51 pm
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!
October 30, 2009 at 7:50 am
We applied the solution listed at the link below to redirect results from the OSSSearchResults page to the Search Center results page. Seems to work fine (at least until we apply an upgrade
http://sharepointsearch.com/cs/blogs/sanjaya/archive/2009/05/03/replacing-osssearchresults-aspx-with-searchcenter-pages-results-aspx.aspx
April 3, 2010 at 4:51 pm
There are many landmarks in the world people climb. Have you ever climbed one and if yes, which one(s)?