Code Examples
  Home arrow Code Examples arrow Searching Body Text with textRange, part 1...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Searching Body Text with textRange, part 1: The Basic Script
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 17
    2005-06-23

    Table of Contents:
  • Searching Body Text with textRange, part 1: The Basic Script
  • Main Script Variants
  • Some Material to Search
  • Coding the Script File
  • How it Works

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Searching Body Text with textRange, part 1: The Basic Script
    (Page 1 of 5 )

    Many websites have search engines that allow visitors to search through the pages of the entire site. That's good, but what if you have single pages that hold a large amount of content by themselves? You might want to provide a way to search through an individual page of your website; your visitors will be grateful for the convenience. This article helps you get started.

    Having a search engine built into your site that allows visitors to search through the pages of your website will add value to almost any site, more so as the site gets bigger. But a search engine such as this won't help visitors search through the text on one particular page of your site. Most of the time, this isn't particularly necessary, but for websites made up of pages that contain a lot of information, this kind of search capability is an excellent feature. These days, there is so much information available, from such a wide variety of sources, that if you don't make it as easy as possible for people to find the information they are looking for with the minimum amount of manual scanning of text, they will go elsewhere to find it.  A large percentage of surfers are rapidly turning into mouse potatoes (couch potatoes of the 21st century).

    Fortunately, IE provides the textRange() object that can be used to turn either a block of text or an entire document (including HTML if you so desire) into a textRange, upon which various methods can be applied. Once such method is the findText() method, that can be used to find a particular letter, word, or sentence. A combination of methods can be used in effect to create an in-document search engine with a scope of the entire body of the document.

    There are several ways in which this could be achieved. While the method that this example is based around may not be the easiest, it provides us with an ideal opportunity to look at some other aspects of JavaScript, such as dialog boxes and exception handling. Okay, exception handling may be a slightly grandiose title for what we'll be doing, but it serves as a good introduction to thinking about what a user of your web page could do to it that is outside the normal operational range of parameters, and how you can cope with this behavior if and when it occurs (which it undoubtedly will!).

    More Code Examples Articles
    More By Dan Wellman


       · Why should I re-implement the "Find (on this page)" functionality that is provided...
       · Hi,That's a very valid point, however, I'm sure there are many people that are...
       · Sorry, can I also point out that many sites now feature an on-the-page text size...
     

    CODE EXAMPLES ARTICLES

    - Handling Animations and Bitmaps Using GDI+ f...
    - Download a Web Page using the WebClient
    - Creating a Chart using Data from a Database ...
    - The Basics of Charting with the MS Chart Con...
    - Searching Body Text with textRange: Enter th...
    - Searching Body Text with textRange: Building...
    - Searching Body Text with textRange, part 1: ...
    - First Steps in Programming
    - Programming in C
    - Quick Introduction to ASF,ASX, and Networkin...
    - SatView: Pointer Perfect, Part 2: Constructi...
    - SatView: Pointer Perfect, Part 1
    - Style Case Studies: Construction Unions
    - Creating an Engine for Games for Windows
    - Style Case Studies: Generic Callbacks




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway