Find on page script

Ερωτήσεις και απαντήσεις σχετικές με την HTML, XHTML και την κατασκευή σελίδων για το Web.

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
Άβαταρ μέλους
nackgr
Δημοσιεύσεις: 1444
Εγγραφή: 22 Ιαν 2006 20:02
Τοποθεσία: Αθηνα
Επικοινωνία:

Find on page script

Δημοσίευση από nackgr » 30 Σεπ 2010 11:39

Γεια σας θελω αν βαλω αυτο σε μια σελιδα μου ,.,. αλλα κατι δεν παει καλα και δεν δουλεύει

Κώδικας: Επιλογή όλων

<script>
<!-- Hide from old browsers

/******************************************
* Find In Page Script -- Submitted/revised by Alan Koontz &#40;alankoontz@REMOVETHISyahoo.com&#41;
* Visit Dynamic Drive &#40;http&#58;//www.dynamicdrive.com/&#41; for full source code
* This notice must stay intact for use
******************************************/

//  revised by Alan Koontz -- May 2003

var TRange = null;
var dupeRange = null;
var TestRange = null;
var win = null;


//  SELECTED BROWSER SNIFFER COMPONENTS DOCUMENTED AT
//  http&#58;//www.mozilla.org/docs/web-developer/sniffer/browser_type.html

var nom = navigator.appName.toLowerCase&#40;&#41;;
var agt = navigator.userAgent.toLowerCase&#40;&#41;;
var is_major   = parseInt&#40;navigator.appVersion&#41;;
var is_minor   = parseFloat&#40;navigator.appVersion&#41;;
var is_ie      = &#40;agt.indexOf&#40;"msie"&#41; != -1&#41;;
var is_ie4up   = &#40;is_ie && &#40;is_major >= 4&#41;&#41;;
var is_not_moz = &#40;agt.indexOf&#40;'netscape'&#41;!=-1&#41;
var is_nav     = &#40;nom.indexOf&#40;'netscape'&#41;!=-1&#41;;
var is_nav4    = &#40;is_nav && &#40;is_major == 4&#41;&#41;;
var is_mac     = &#40;agt.indexOf&#40;"mac"&#41;!=-1&#41;;
var is_gecko   = &#40;agt.indexOf&#40;'gecko'&#41; != -1&#41;;
var is_opera   = &#40;agt.indexOf&#40;"opera"&#41; != -1&#41;;


//  GECKO REVISION

var is_rev=0
if &#40;is_gecko&#41; &#123;
temp = agt.split&#40;"rv&#58;"&#41;
is_rev = parseFloat&#40;temp&#91;1&#93;&#41;
&#125;


//  USE THE FOLLOWING VARIABLE TO CONFIGURE FRAMES TO SEARCH
//  &#40;SELF OR CHILD FRAME&#41;

//  If you want to search another frame, change from "self" to
//  the name of the target frame&#58;
//  e.g., var frametosearch = 'main'

//var frametosearch = 'main';
var frametosearch = self;


function search&#40;whichform, whichframe&#41; &#123;

//  TEST FOR IE5 FOR MAC &#40;NO DOCUMENTATION&#41;

if &#40;is_ie4up && is_mac&#41; return;

//  TEST FOR NAV 6 &#40;NO DOCUMENTATION&#41;

if &#40;is_gecko && &#40;is_rev <1&#41;&#41; return;

//  TEST FOR Opera &#40;NO DOCUMENTATION&#41;

if &#40;is_opera&#41; return;

//  INITIALIZATIONS FOR FIND-IN-PAGE SEARCHES

if&#40;whichform.findthis.value!=null && whichform.findthis.value!=''&#41; &#123;

       str = whichform.findthis.value;
       win = whichframe;
       var frameval=false;
       if&#40;win!=self&#41;
&#123;

       frameval=true;  // this will enable Nav7 to search child frame
       win = parent.frames&#91;whichframe&#93;;

&#125;

    
&#125;

else return;  //  i.e., no search string was entered

var strFound;

//  NAVIGATOR 4 SPECIFIC CODE

if&#40;is_nav4 && &#40;is_minor < 5&#41;&#41; &#123;
   
  strFound=win.find&#40;str&#41;; // case insensitive, forward search by default

//  There are 3 arguments available&#58;
//  searchString&#58; type string and it's the item to be searched
//  caseSensitive&#58; boolean -- is search case sensitive?
//  backwards&#58; boolean --should we also search backwards?
//  strFound=win.find&#40;str, false, false&#41; is the explicit
//  version of the above
//  The Mac version of Nav4 has wrapAround, but
//  cannot be specified in JS

 
        &#125;

//  NAVIGATOR 7 and Mozilla rev 1+ SPECIFIC CODE &#40;WILL NOT WORK WITH NAVIGATOR 6&#41;

if &#40;is_gecko && &#40;is_rev >= 1&#41;&#41; &#123;
   
    if&#40;frameval!=false&#41; win.focus&#40;&#41;; // force search in specified child frame
    strFound=win.find&#40;str, false, false, true, false, frameval, false&#41;;

//  The following statement enables reversion of focus 
//  back to the search box after each search event 
//  allowing the user to press the ENTER key instead
//  of clicking the search button to continue search.
//  Note&#58; tends to be buggy in Mozilla as of 1.3.1
//  &#40;see www.mozilla.org&#41; so is excluded from users 
//  of that browser.

    if &#40;is_not_moz&#41;  whichform.findthis.focus&#40;&#41;;

//  There are 7 arguments available&#58;
//  searchString&#58; type string and it's the item to be searched
//  caseSensitive&#58; boolean -- is search case sensitive?
//  backwards&#58; boolean --should we also search backwards?
//  wrapAround&#58; boolean -- should we wrap the search?
//  wholeWord&#58; boolean&#58; should we search only for whole words
//  searchInFrames&#58; boolean -- should we search in frames?
//  showDialog&#58; boolean -- should we show the Find Dialog?


&#125;

 if &#40;is_ie4up&#41; &#123;

  // EXPLORER-SPECIFIC CODE revised 5/21/03

  if &#40;TRange!=null&#41; &#123;
      
   TestRange=win.document.body.createTextRange&#40;&#41;;
 
      

   if &#40;dupeRange.inRange&#40;TestRange&#41;&#41; &#123;

   TRange.collapse&#40;false&#41;;
   strFound=TRange.findText&#40;str&#41;;
    if &#40;strFound&#41; &#123;
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = win.document.body.scrollTop + TRange.offsetTop;
        TRange.select&#40;&#41;;
        &#125;


   &#125;
   
   else &#123;

     TRange=win.document.body.createTextRange&#40;&#41;;
     TRange.collapse&#40;false&#41;;
     strFound=TRange.findText&#40;str&#41;;
     if &#40;strFound&#41; &#123;
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = TRange.offsetTop;
        TRange.select&#40;&#41;;
        &#125;



   &#125;
  &#125;
  
   if &#40;TRange==null || strFound==0&#41; &#123;
   TRange=win.document.body.createTextRange&#40;&#41;;
   dupeRange = TRange.duplicate&#40;&#41;;
   strFound=TRange.findText&#40;str&#41;;
    if &#40;strFound&#41; &#123;
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = TRange.offsetTop;
        TRange.select&#40;&#41;;
        &#125;

   
   &#125;

 &#125;

  if &#40;!strFound&#41; alert &#40;"String '"+str+"' not found!"&#41; // string not found

        
&#125;
// -->
</script>

<!--  EXAMPLE FORM OF FIND-IN-PAGE SEARCH USING SUBMIT &#40;ALLOWING 'ENTER/RETURN' KEY PRESS EVENT&#41; -->
<form name="form1" onSubmit="search&#40;document.form1, frametosearch&#41;; return false"><input type="text" name="findthis" size="15" title="Press 'ALT s' after clicking submit to repeatedly search page"> <input type="submit" value="Find in Page" ACCESSKEY="s"></form>
το βρηκα εδω
http://www.dynamicdrive.com/dynamicindex11/findpage.htm

θελω να ψαχνει σε μια μονο σελιδα, σε ενα table που εχει διεύθυνσης και αριθμούς
αυταααααααααααα...
e-Byte.gr
Dafuq.gr

Απάντηση

Επιστροφή στο “HTML και XHTML”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες