Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts

    Find text inside page script

    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
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #3
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72 W. 48' 57" , 41 N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    here's an article at evolt that outlines how to do that, and provides some sample code:

    http://www.evolt.org/article/DHTML_T...028/index.html
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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

    COMMENTS WANTED DEAD OR ALIVE

  • #5
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    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.
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The "Find" "All" and "Exact Case" is a little hard to read in the popup window.

    That is a really cool script.

  • #7
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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!!

  • #8
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.

  • #9
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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

  • #10
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    http://www10.brinkster.com/a1ien51/Scripts/FindBar.htm

    I updated it , 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

  • #11
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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

  • #12
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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

  • #13
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts

    Now Added: Query String Search

    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/S...is+find+script

    A1ien51

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #15
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •