Highlight search keywords in the WSS search results page

Source: Internet
Author: User
Tags continue

Find the search results page in the folder "C:\Program Files\Common Files\Microsoft Shared\Web Server extensions\60\template\layouts\2052" searchresults.aspx, edit the file.

Insert the following JavaScript before closing the label "</body>".

var strsearchterm = document.forms["Frmsearch"].elements["searchstring"].value;
Highlightsearchterm (Strsearchterm);
function Highlightsearchterm (strsearchterm)
{
var celltables = document.all.tags ("table");
var strsearchterm = Strsearchterm.tolowercase ();
if (Strsearchterm = "")
Return
for (var II = 0; II < celltables.length; ii++)
{
if ((celltables[ii].all["Frmsearch"]!= null) | | (Celltables[ii].classname!= ""))
Continue
var celltags = celltables[ii].all.tags ("TD");
for (var III = 0; III < celltags.length; iii++)
{
if (celltags[iii].classname!= "Ms-vb")
Continue
var strbodytext = celltags[iii].innerhtml;
var strText = Strbodytext.tolowercase ();
var i =-1;
var strnewtext = "";
while (Strbodytext.length > 0)
{
i = Strtext.indexof (Strsearchterm, i+1);
if (I < 0)
{
strNewText + = Strbodytext;
Strbodytext = "";
}
Else
{
if (Strbodytext.lastindexof (">", i) >= strbodytext.lastindexof ("<", i))
{
if (Strtext.lastindexof ("/script>", i) >= strtext.lastindexof ("<script", I))
{
strNewText + + strbodytext.substring (0, I) + "<b style= ' Color:black;" Background-color: #ffff66 ' > ' + strbodytext.substr (i, strsearchterm.length) + "</B>";
Strbodytext = strbodytext.substr (i + strsearchterm.length);
StrText = Strbodytext.tolowercase ();
i =-1;
}
}
}
}
celltags[iii].innerhtml = strNewText;
}
}
}

Save and close the paging file.

Now, when you search for a keyword in the WSS site, the result will be the same as Google highlighting the keyword. J

Original address: http://msd2d.com/newsletter_tip.aspx?section=sharepoint&id=c89e3424-d7e6-4f79-9c89-be219513357b

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.