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.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript search - help

    I have a javascript that allows me to search text on a page.

    What I want to do is to limit the search area and not search the entire page.

    Can anyone help me with this?

    Here is an example page:

    http://merchantcertified.com/search.htm

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,603
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    Easy.

    Put <div>...</div> tags around the part you want to search and then only search within that <div>.

    But that code you are using is *ANCIENT*.

    Code:
    var NS4 = (document.layers);    
    var IE4 = (document.all);
    Really??? You think *ANYBODY* is still using either MSIE 4 (1999) or Netscape 4 (1998)????

    No way.

    And that code doesn't work at all in Firefox. Or Chrome. So you have just limited yourself to about 40% of all browsers (that is, MSIE only...and maybe not even MSIE 9).

    WAY WAY WAY past time to chuck that code and use something *modern*.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

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