PDA

View Full Version : Find text inside page script


WA
09-12-2002, 11:29 AM
Someone submitted this script my way, and I thought I'd post it here first, to see if people can come up with improvements.

This is a find text inside page script. Basically one would enter any text into a textbox, and the script searches for matches on the page, and highlights it if found. The script can be specified to search text in another frame or iframe.

Right now the script works in IE plus NS7. I was hoping it could be modified to work in NS6 as well.

Here it is: http://alumni.umbc.edu/~akoont1/script/findinpage.html

scroots
09-12-2002, 10:14 PM
a text affect could be added, so when you search for "ace" or whatever every word ace would have a yellow background highlight or something, like when you look at html copies of .pdf`s on google.

scroots

joh6nn
09-13-2002, 04:32 AM
here's an article at evolt that outlines how to do that, and provides some sample code:

http://www.evolt.org/article/DHTML_Text_Marker_An_Experiment/17/29028/index.html

A1ien51
09-15-2002, 08:28 AM
I thought that the solution that Joh6nn posted was a little to much for such a simple task. So I decied to strat from scratch and make it a little easier and browser friendly. I came up with the following script. Please Read the Page.

http://www10.brinkster.com/A1ien51/scripts/FindBar.htm

Going to get sleep now..........Will be back to give it more power tomorrow.

A1ien51

:thumbsup: COMMENTS WANTED DEAD OR ALIVE:thumbsup:

WA
09-16-2002, 12:21 AM
Quite impressive A1ien51! Here are some suggestions:

1) Make the "All" option a checkbox, so users can toogle between searching for a match one at a time, or all at once

2) I would remove the drop down color box, and just create a variable inside the script that specifies this. Too many options can be confusing from a user point of view.

3) Perhaps sharpen up the interface a bit

Overall, very impressive! And I see it works in Mozilla as well.

allida77
09-16-2002, 07:03 PM
The "Find" "All" and "Exact Case" is a little hard to read in the popup window.

That is a really cool script.:thumbsup:

A1ien51
09-16-2002, 09:12 PM
Depending on how I feel tonight after classes and work, I might update it, If not tonight, it will be in a couple of days.

Right now i am programming legos...oh boy what find with drag and drop coding interface....wohooo....

yes, legos are computerize and cost $200 for a set!!

oracleguy
09-17-2002, 11:39 PM
Originally posted by A1ien51


yes, legos are computerize and cost $200 for a set!!

I have one of those. They are a lot of fun.

A1ien51
09-21-2002, 07:42 AM
I see what you said about the colors.....lol.....I forgot that my contrast is set low on my computer......I saw this on my girlfriends computer and almost died laughing!!

Been very busy, but i am working on making the code cleaner.

A1ien51

A1ien51
09-21-2002, 04:22 PM
http://www10.brinkster.com/a1ien51/Scripts/FindBar.htm

:eek: I updated it:eek: , BUT it is not 100% done. I need to find a better way of checking for tags like   & < > &quote;

right now if you check for anything that appears inside of it, the html tag will show up in the text.

But, i got all of the matching stuff to work very good, there are some problems with it. Search the word case with no parameters checked. Then check the exact word and research. I still do not recognize quotes or any other character.

I am also working on searching one at a time, bu this will be done after the regular search is completed.

A1ien51

A1ien51
09-25-2002, 01:46 AM
http://www10.brinkster.com/a1ien51/Scripts/FindBar.htm

hey i updated it....can you people please look for errors!!! Search certain things and see if it is found....

exact is still buggy....The script willl not find it if there is any character besides a space before or after it....almost got this fixed, but not in this update. I got it to ignore the basic tags....less then,greater then,and sign, quote, and extra space......is there any others I missed that are of importance??

After I can fix any bugs you find, plus what I already know,,,,I will then do the finishing touches which are listed on the page.

Thanks for your time,
A1ien51

A1ien51
11-26-2002, 03:35 AM
I updated it, still is ugly code, but it gets the job done. Figured out my mistake!!

http://www10.brinkster.com/a1ien51/Scripts/FindBar.htm

I have another version in the works that works with auto. searches......

A1ien51

A1ien51
11-27-2002, 07:30 AM
The page can be searched with the query string......
(The page text has not changed from the find bar, so ignore it)

http://www10.brinkster.com/a1ien51/Scripts/qsfind.htm?the+this+find+script

A1ien51

whammy
12-06-2002, 02:32 AM
It looks to me like you need to use regular expressions to overcome the search problems (although you're definitely headed in the right direction!), instead of "slicing and dicing"... ;)

A1ien51
12-06-2002, 02:44 AM
joh6nn yelled at me for no using them before......The script works...I am too lazy right now to go through the script and convert it to reg. exp. Trying to graduate college right now....lol

There is no real search problems that I have found, I just missed subtracting a value inside of a for loop when it detected a value.

I know the code can be cut in half since I reinvented the wheel. I avoided replace with the strings and used my old function I wrote.

I am going to avoid javascript for 3 weeks and then pray I find a job and then start coding again.

whammy
12-06-2002, 02:46 AM
Sounds like joh6nn and I think alike somewhat (probably since he has incidentally taught me quite a bit about programming, perhaps? I still have a lot to learn though!). :)

The only reason I said that in the first place, is it looks like a lot of ASP scripts I have shortened considerably (that were using loops) by using regular expressions instead. :)

They beat the heck out of loops... as long as it works though, you can't complain too much. :D