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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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


    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


       · where is the actual javascript code?
       · hi, whats your email and I'll send you the source files directlyDan
     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek