<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>ProductCart Shopping Cart Software Forums : Search Text Highlighter</title>
  <link>https://forum.productcart.com/</link>
  <description><![CDATA[This is an XML content feed of; ProductCart Shopping Cart Software Forums : Customizing ProductCart : Search Text Highlighter]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Sat, 04 Apr 2026 11:41:03 +0000</pubDate>
  <lastBuildDate>Tue, 27 Jan 2009 12:38:15 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://forum.productcart.com/RSS_post_feed.asp?TID=2389</WebWizForums:feedURL>
  <image>
   <title><![CDATA[ProductCart Shopping Cart Software Forums]]></title>
   <url>https://forum.productcart.com/forum_images/pc_logo_50.png</url>
   <link>https://forum.productcart.com/</link>
  </image>
  <item>
   <title><![CDATA[Search Text Highlighter : Yes, I see that on the advanced...]]></title>
   <link>https://forum.productcart.com/search-text-highlighter_topic2389_post8549.html#8549</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forum.productcart.com/member_profile.asp?PF=1255">JamesD</a><br /><strong>Subject:</strong> 2389<br /><strong>Posted:</strong> 27-January-2009 at 12:38pm<br /><br />Yes, I see that on the advanced search it's not working... thanks for pointing that out.&nbsp; I realized that's due to the fact that ProductCart sends the keyword variable as "keyWord" (with a capital W), and since Javascript is case-sensitive it's not seeing it.&nbsp; I've edited the code in the external js to fix this:<DIV>&nbsp;</DIV><DIV>function highlightOnLoad() {<BR>&nbsp; // Get search string<BR>&nbsp; //if (/keyword\=/.test(window.location.search)) {<BR>&nbsp;&nbsp; if (/keyword\=/.test(window.location.search) || /keyWord\=/.test(window.location.search)) {&nbsp; <BR>&nbsp; //if (window.location.search != "") {<BR>&nbsp;&nbsp;&nbsp; var searchString = getSearchString();<BR>&nbsp;&nbsp;&nbsp; // Starting node, parent to all nodes you want to search<BR>&nbsp;&nbsp;&nbsp; var textContainerNode = document.getElementById("content");</DIV><DIV>&nbsp;&nbsp;&nbsp; // Informational message for search<BR>&nbsp;&nbsp;&nbsp; var searchInfo = 'Search Results for: ';</DIV><DIV>&nbsp;&nbsp;&nbsp; // Split search terms on '|' and iterate over resulting array<BR>&nbsp;&nbsp;&nbsp; var searchTerms = searchString.split('|');<BR>&nbsp;&nbsp;&nbsp; for (var i in searchTerms) &nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // The regex is the secret, it prevents text within tag declarations to be affected<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var regex = new RegExp("&gt;(&#091;^&lt;&#093;*)?("+searchTerms<em>+")(&#091;^&gt;&#093;*)?&lt;","ig");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; highlightTextNodes(textContainerNode, regex, i);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }<BR>}</DIV><DIV>// Pull the search string out of the URL<BR>function getSearchString() {<BR>&nbsp; // Return sanitized search string if it exists<BR>&nbsp; var rawSearchString;<BR>&nbsp; if(/keyword\=/.test(window.location.search)) {rawSearchString = window.location.search.replace(/&#091;a-zA-Z0-9\?\&amp;\=\%\#&#093;+keyword\=(\w+)(\&amp;.*)?/,"$1");}<BR>&nbsp; else {rawSearchString = window.location.search.replace(/&#091;a-zA-Z0-9\?\&amp;\=\%\#&#093;+keyWord\=(\w+)(\&amp;.*)?/,"$1");}<BR>&nbsp; // Replace '+' with '|' for regex<BR>&nbsp; // Also replace '%20' if your cms/blog uses this instead (credit to erlando for adding this)<BR>&nbsp; return rawSearchString.replace(/\%20|\+/g,"\|");<BR>}</DIV><DIV>function highlightTextNodes(element, regex, termid) {<BR>&nbsp; var tempinnerHTML = element.innerHTML;<BR>&nbsp; // Do regex replace<BR>&nbsp; // Inject span with class of 'highlighted termX' for google style highlighting<BR>&nbsp; element.innerHTML = tempinnerHTML.replace(regex,'&gt;$1&lt;span class="highlighted term'+termid+'"&gt;$2&lt;/span&gt;$3&lt;');<BR>}</DIV><DIV>window.onload = highlightOnLoad;</DIV>]]>
   </description>
   <pubDate>Tue, 27 Jan 2009 12:38:15 +0000</pubDate>
   <guid isPermaLink="true">https://forum.productcart.com/search-text-highlighter_topic2389_post8549.html#8549</guid>
  </item> 
  <item>
   <title><![CDATA[Search Text Highlighter : That is then only a partial solution...]]></title>
   <link>https://forum.productcart.com/search-text-highlighter_topic2389_post8542.html#8542</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forum.productcart.com/member_profile.asp?PF=578">leeflang</a><br /><strong>Subject:</strong> 2389<br /><strong>Posted:</strong> 27-January-2009 at 12:01pm<br /><br />That is then only a partial solution (BTW, I saw it does not work on main search, only on search result page), usable for 'short product descriptions'. With 'long product descriptions' it would not work, since buyers would still have to take a lot of time navigating the actual descriptions. <DIV>&nbsp;</DIV><DIV>There are quite a lot of 'hosted search engine services out there and they offer both search highlighting functionalities. Maybe it is a better option to use such a service?</DIV><span style="font-size:10px"><br /><br />Edited by leeflang - 27-January-2009 at 12:21pm</span>]]>
   </description>
   <pubDate>Tue, 27 Jan 2009 12:01:15 +0000</pubDate>
   <guid isPermaLink="true">https://forum.productcart.com/search-text-highlighter_topic2389_post8542.html#8542</guid>
  </item> 
  <item>
   <title><![CDATA[Search Text Highlighter : It searches the entire page content...]]></title>
   <link>https://forum.productcart.com/search-text-highlighter_topic2389_post8541.html#8541</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forum.productcart.com/member_profile.asp?PF=1255">JamesD</a><br /><strong>Subject:</strong> 2389<br /><strong>Posted:</strong> 27-January-2009 at 11:13am<br /><br />It searches the entire page content for the search terms and shows those terms highlighted on the search results page only.<DIV></DIV><DIV>&nbsp;</DIV><DIV>You can see it in action on this site I did:&nbsp; <a href="http://www.batteries&#111;nthego.com" target="_blank">http://www.batteriesonthego.com</A></DIV>]]>
   </description>
   <pubDate>Tue, 27 Jan 2009 11:13:25 +0000</pubDate>
   <guid isPermaLink="true">https://forum.productcart.com/search-text-highlighter_topic2389_post8541.html#8541</guid>
  </item> 
  <item>
   <title><![CDATA[Search Text Highlighter :  Does this script highlight entered...]]></title>
   <link>https://forum.productcart.com/search-text-highlighter_topic2389_post8538.html#8538</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forum.productcart.com/member_profile.asp?PF=578">leeflang</a><br /><strong>Subject:</strong> 2389<br /><strong>Posted:</strong> 27-January-2009 at 10:39am<br /><br />Does this script highlight entered search terms only in search results page or also in individual product pages?<span style="font-size:10px"><br /><br />Edited by leeflang - 27-January-2009 at 10:39am</span>]]>
   </description>
   <pubDate>Tue, 27 Jan 2009 10:39:41 +0000</pubDate>
   <guid isPermaLink="true">https://forum.productcart.com/search-text-highlighter_topic2389_post8538.html#8538</guid>
  </item> 
  <item>
   <title><![CDATA[Search Text Highlighter : I would like to mention that credit...]]></title>
   <link>https://forum.productcart.com/search-text-highlighter_topic2389_post8501.html#8501</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forum.productcart.com/member_profile.asp?PF=1255">JamesD</a><br /><strong>Subject:</strong> 2389<br /><strong>Posted:</strong> 25-January-2009 at 5:38pm<br /><br />I would like to mention that credit for the js code goes to Eric Wendelin:&nbsp; <a href="http://eriwen.com/java&#115;cript/highlight-search-results-with-js/" target="_blank">http://eriwen.com/javascript/highlight-search-results-with-js/</A>]]>
   </description>
   <pubDate>Sun, 25 Jan 2009 17:38:01 +0000</pubDate>
   <guid isPermaLink="true">https://forum.productcart.com/search-text-highlighter_topic2389_post8501.html#8501</guid>
  </item> 
  <item>
   <title><![CDATA[Search Text Highlighter : Here are the simple steps I used...]]></title>
   <link>https://forum.productcart.com/search-text-highlighter_topic2389_post8500.html#8500</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forum.productcart.com/member_profile.asp?PF=1255">JamesD</a><br /><strong>Subject:</strong> 2389<br /><strong>Posted:</strong> 25-January-2009 at 5:33pm<br /><br /><P>Here are the simple steps I used to add search text highlighting to my ProductCart.</P><DIV></DIV><DIV></DIV>FYI: I did this to a ProductCart v.3.5 cart, however I believe this will work on most versions. The text in <FONT color=#006600>green </FONT>below refers to code you'll need to insert.<DIV>&nbsp;</DIV><DIV>Step 1:&nbsp; Unzip this file:&nbsp; <a href="http://www.earlyimpact.com/forum/uploads/1255/highlighter.zip" target="_blank">uploads/1255/highlighter.zip</A>, and place in the existing&nbsp;/includes/javascripts folder.</DIV><DIV>&nbsp;</DIV><DIV>Step 2:&nbsp; Add a link to the js file in the existing header.asp file:&nbsp; <FONT color=#006600>&lt;script src="../includes/javascripts/highlighter.js" type="text/javascript"&gt;&lt;/script&gt;</FONT></DIV><DIV>&nbsp;</DIV><DIV>Step 3:&nbsp; Insert the following line of code in header.asp, right after the &lt;body&gt; tag</DIV><DIV><FONT color=#006600>&lt;div id="content"&gt;</FONT></DIV><DIV>&nbsp;</DIV><DIV>Step 4:&nbsp; Insert the following line of code in footer.asp, right before the &lt;/body&gt; tag</DIV><DIV><FONT color=#006600>&lt;/div&gt;</FONT></DIV><DIV>&nbsp;</DIV><DIV>Step 5:&nbsp; Add the following&nbsp;code at the end of the&nbsp;existing file pcHeaderFooter08.css:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#006600>/* ----- Search Text Highlighting styles ----- */</FONT></DIV><DIV><FONT color=#006600>span.term0 {<BR>&nbsp; background-color: #99ccff;<BR>}<BR>span.term1 {<BR>&nbsp; background-color: #99ccff;<BR>}<BR>span.term2 {<BR>&nbsp; background-color: #99ccff;<BR>}</FONT></DIV><DIV><FONT color=#006600></FONT>&nbsp;</DIV><DIV><FONT color=#000000>** Note regarding the css code:&nbsp; Each span.term style refers to the number of&nbsp;search terms entered by the user.&nbsp; In other words, if they enter more than one search term, each term can be given&nbsp;a different style (term0, term1, etc.)&nbsp;&nbsp;You can add additional term styles if you want; just name them as shown:&nbsp; term0, term1, term2, term3, etc.</FONT></DIV>]]>
   </description>
   <pubDate>Sun, 25 Jan 2009 17:33:37 +0000</pubDate>
   <guid isPermaLink="true">https://forum.productcart.com/search-text-highlighter_topic2389_post8500.html#8500</guid>
  </item> 
 </channel>
</rss>