Comments on: “Search on this Page” using jQuery http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/ No GeekSpeak on SharePoint 2007 WSS and MOSS Mon, 22 Nov 2010 21:35:20 -0500 http://wordpress.org/?v=2.8.6 hourly 1 By: Michael http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-77459 Michael Sat, 26 Jun 2010 07:16:50 +0000 http://www.endusersharepoint.com/?p=951#comment-77459 Great Code! Modified it to jQueryiedly scroll to the first term or to scroll back to the top if there is nothing found: [sourcecode lang="javascript"] keyup(function() { $(instance.textWrapper).html(instance.getOriginalText()); if (this.value.length >= instance.startSearchingLength) { var searchText = escape(this.value); var regx = new RegExp("(" + searchText + ")", 'gi'); var selector = 'p:Contains("' + searchText + '")'; $(instance.textWrapper).each(function() { var text = $(this).html(); text = text.replace(regx, '$1'); $(this).html(text); }); $(function(){ $('html, body').animate({scrollTop:$('#scrollToMe').offset().top}, 'slow'); return false; }); } else { $(function(){ $('html, body').animate({scrollTop:0}, 'slow'); return false; }); } }) [/sourcecode] However this script is almost completely unusable because of the html code highlighting also!! has anyone found a solution to that? For clarification: in the example try searching for 'str'-- this will add the span tag around the character that appear inside the <strong> tag in side the HTML Great Code! Modified it to jQueryiedly scroll to the first term or to scroll back to the top if there is nothing found:

keyup(function() {
        $(instance.textWrapper).html(instance.getOriginalText());

        if (this.value.length &gt;= instance.startSearchingLength) {
          var searchText = escape(this.value);
          var regx = new RegExp("(" + searchText + ")", 'gi');
          var selector = 'p:Contains("' + searchText + '")';
          $(instance.textWrapper).each(function() {
            var text = $(this).html();
            text = text.replace(regx, '$1');
            $(this).html(text);
          });
		  $(function(){
				$('html, body').animate({scrollTop:$('#scrollToMe').offset().top}, 'slow');
				return false;
			});
        }
		else
		{
			$(function(){
				$('html, body').animate({scrollTop:0}, 'slow');
				return false;
			});
		}
      })

However this script is almost completely unusable because of the html code highlighting also!! has anyone found a solution to that?

For clarification: in the example try searching for ’str’– this will add the span tag around the character that appear inside the tag in side the HTML

]]>
By: AJ http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-28129 AJ Wed, 03 Feb 2010 18:37:21 +0000 http://www.endusersharepoint.com/?p=951#comment-28129 You can see the problem using your example by typing in "str" or even "/.". I thought I had found a fix by adding the code below: [sourcecode lang="javascript"] var i = -1; i = text.indexOf(searchText, i+1); if (text.lastIndexOf(">", i) >= text.lastIndexOf("<", i)) { text = text.replace(regx, '$1'); $(this).html(text); } [/sourcecode] This isn't a good enough solution as it doesn't apply the background to any 'on screen' text that matches any html element names. Has anyone come up with a suitably robust application of this concept using jQuery? You can see the problem using your example by typing in “str” or even “/.”. I thought I had found a fix by adding the code below:

var i = -1;
i = text.indexOf(searchText, i+1);
if (text.lastIndexOf("&gt;", i) &gt;= text.lastIndexOf("&lt;&quot;, i)) {
  text = text.replace(regx, &#039;$1');
  $(this).html(text);
}

This isn’t a good enough solution as it doesn’t apply the background to any ‘on screen’ text that matches any html element names.

Has anyone come up with a suitably robust application of this concept using jQuery?

]]>
By: AJ http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-27489 AJ Tue, 02 Feb 2010 11:52:10 +0000 http://www.endusersharepoint.com/?p=951#comment-27489 Has anyone managed to figure out how to exclude element tags? Joyce had this problem back in May last year and I was just wondering if anyone had managed to find a workaround. This is a lovely concept, but I am having the same problem where my implementation of the above code is displaying 'class' tags and showing text from URIs. Has anyone managed to figure out how to exclude element tags? Joyce had this problem back in May last year and I was just wondering if anyone had managed to find a workaround.

This is a lovely concept, but I am having the same problem where my implementation of the above code is displaying ‘class’ tags and showing text from URIs.

]]>
By: Siddharth Roy http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-15461 Siddharth Roy Thu, 30 Jul 2009 16:10:48 +0000 http://www.endusersharepoint.com/?p=951#comment-15461 Hi, Is there a way to execute a SQL Query (which has a variable input)in a SharePoint site such that when users type anything in a textbox, that value is taken as input for the sql query. I want to do it without server-side coding? Any OOTB method??? Thanks, Sid Hi,

Is there a way to execute a SQL Query (which has a variable input)in a SharePoint site such that when users type anything in a textbox, that value is taken as input for the sql query.

I want to do it without server-side coding? Any OOTB method???

Thanks,
Sid

]]>
By: Joyce http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-13107 Joyce Mon, 25 May 2009 20:38:34 +0000 http://www.endusersharepoint.com/?p=951#comment-13107 This is great! One problem: is there a way to make this NOT search within tag contents? For example, I have images with width and height attributes specified within the img tag. If I search the word "width," suddenly the contents of the img tag appear visible on the page next to the image and the width attribute name is highlighted. If I search a word in the alt text of an image, the image blows up to be enormous and the alt tag text appears, highlighted. This is rather inconvenient. It's great that it works for text enclosed in closing and end tags in the #body (as shown in the "cras" example above), but is there any way to discount text within the actual element tags? Thanks! Joyce This is great!

One problem: is there a way to make this NOT search within tag contents? For example, I have images with width and height attributes specified within the img tag. If I search the word “width,” suddenly the contents of the img tag appear visible on the page next to the image and the width attribute name is highlighted. If I search a word in the alt text of an image, the image blows up to be enormous and the alt tag text appears, highlighted. This is rather inconvenient. It’s great that it works for text enclosed in closing and end tags in the #body (as shown in the “cras” example above), but is there any way to discount text within the actual element tags?

Thanks! Joyce

]]>
By: Trey http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-12907 Trey Sun, 17 May 2009 20:52:46 +0000 http://www.endusersharepoint.com/?p=951#comment-12907 Did anyone check Dana's request? Any thoughts on it? I'm thinking of making custom arrays and connecting the selector from the query. Thoughts? Did anyone check Dana’s request? Any thoughts on it? I’m thinking of making custom arrays and connecting the selector from the query. Thoughts?

]]>
By: Dimcho Tsanov http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-12152 Dimcho Tsanov Wed, 22 Apr 2009 13:28:03 +0000 http://www.endusersharepoint.com/?p=951#comment-12152 Hi, I tried to recreate the example but I can not run anything. I recived am error: Microsoft JScript runtime error: 'Imtech' is undefined. Does anyone know why is that ? Thank you. Hi,
I tried to recreate the example but I can not run anything. I recived am error: Microsoft JScript runtime error: ‘Imtech’ is undefined.
Does anyone know why is that ?

Thank you.

]]>
By: dana http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-10800 dana Mon, 23 Feb 2009 18:59:03 +0000 http://www.endusersharepoint.com/?p=951#comment-10800 Is it possible to assign multiple target (invisible) search terms to the final highlighted outcome? For example if i were to type in architecture, multiple items will be highlighted in addition to architecture. Thank you Dana Is it possible to assign multiple target (invisible) search terms to
the final highlighted outcome?

For example if i were to type in architecture, multiple items will be highlighted in addition to architecture.

Thank you

Dana

]]>
By: dana http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-10798 dana Mon, 23 Feb 2009 18:57:23 +0000 http://www.endusersharepoint.com/?p=951#comment-10798 1. is it possible to highlight more than one word at a time? 2. Is it possible to highlight based on words that are not visible. For example if a user typed in "architecture' to the search box, then 4 or 5 items would be highlighted? I have target words for each highlightable element, is it possible to include these target words in the search? Thank you Dana 1. is it possible to highlight more than one word at a time?

2. Is it possible to highlight based on words that are not visible.
For example if a user typed in “architecture’ to the search box, then 4 or 5 items would be highlighted?

I have target words for each highlightable element, is it possible to include these target words in the search?

Thank you

Dana

]]>
By: Bamboo Guru Blogs http://www.endusersharepoint.com/2008/11/17/search-on-this-page-using-jquery/comment-page-1/#comment-10547 Bamboo Guru Blogs Wed, 18 Feb 2009 10:40:40 +0000 http://www.endusersharepoint.com/?p=951#comment-10547 <strong>JQuery - A Fresh Look at What YOU Can Do On SharePoint Without Server Code...</strong> Client side coding has taken a leap in the right direction, and SharePoint people need to take note.... JQuery – A Fresh Look at What YOU Can Do On SharePoint Without Server Code…

Client side coding has taken a leap in the right direction, and SharePoint people need to take note….

]]>