SunQuest
 
       Code Examples
  Home arrow Code Examples arrow Page 3 - Searching Body Text with textRange: Enter ...
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 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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: Enter the Gecko
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 39
    2005-07-07

    Table of Contents:
  • Searching Body Text with textRange: Enter the Gecko
  • The first function
  • The second function
  • Create a master script file

  • 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
     
     
    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: Enter the Gecko - The second function


    (Page 3 of 4 )

    The second function can be added with the following code:

    function searchNext() {

      if (button1clicked != 1) {

        window.alert("No search word entered!");

      } else {

        If (searchWord == null) {

          Window.alert("No search word entered!");

        return false

        }

        match = window.find(searchWord, false, false, false, true, false, false);

        if (match == false) {

          window.alert("No more matches");

        }

      }

    }

    It first checks that the flag is set to one and produces an appropriate message if not. Providing the flag is set, it simply calls the find method of the window object again. Not only is this method smart enough to do the searching and highlighting on its own, it is able to keep track of words it has found already and automatically move on to and highlight the next occurrence of the specified search word! Again, this cuts down considerably on our code. The script will continue highlighting matches until it finds no more and produces the final alert to say that no more instances of the word exist.

    That’s it. Save the file as behaviour(moz).js and amend the HTML file to link to the new one. Open the HTML page in any of the supported Gecko based browsers and see it in action.

    More Code Examples Articles
    More By Dan Wellman


     

    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