JavaScript Reference/Javascript Methods/findText

Материал из Web эксперт
Версия от 11:22, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"findText()" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function1() {

   var m = document.body.createTextRange();
   m.findText(""test"");
   m.select(); 

} </script>

Search the "test" word in this paragraph

<button onclick="function1();">Find test</button> </body> </html>


     </source>
   
  


"findText()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |TextRange | +----------------+--------------------------------------------------------------+

     </source>
   
  


"findText()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Searches a TextRange object for the specified string and highlights it if found.

Syntax:

textRangeName.findText(param1, param2, param3) Parameters:

   param1   Required; the text to find.
   param2   Optional; the number of characters of the text range. 
            A positive value indicates a forward count; 
            a negative one indicates a backward count.
   param3   Optional; the type of search. 
                    1           search backwards
                    2           match whole words only
                    4           make search case sensitive
                    131072      search for byte values), 
                    536870912   match special marks), 
                    1073741824  match Far East characters
                    2147483648  match Hebrew/Arabic characters
   
     
     </source>