Websitenize yada blogunuza Arama motoru koymakta zorlanıyor musunuz? Bu basit "Sayfa İçi Arama Kodu" sayesinde, ziyaretçileriniz sayfanızda direkt arama yapabilir! "Bu Sayfada Ara" düğmesi ve küçük bir arama kutusu ile kullanılabilen bu javascript ve html kodu sayesinde ziyaretçileriniz tarayıcıların arama işlevini kullanmak zorunda kalmayacak!


PHP- Kodu:

<!--Kod Dostu Sayfa İçi Arama Formu START-->


<script>


<!-- Hide from old browsers



/******************************************


* Find In Page Script -- Submitted/revised by Alan Koontz ([email protected]yahoo.com )


* Visit Kod Dostu (Moved Temporarily) for full source code


* "Sayfa İçi Arama Kutusu" by Kod Dostu


* This notice must stay intact for use


******************************************/


var TRange = null;


var dupeRange = null;


var TestRange = null;


var win = null;




var nom = navigator.appName.toLowerCase() ;


var agt = navigator.userAgent.toLowerCase ();


var is_major = parseInt(navigator.appVersion);


var is_minor = parseFloat(navigator.appVersion );


var is_ie = (agt.indexOf("msie") != -1);


var is_ie4up = (is_ie && (is_major >= 4));


var is_not_moz = (agt.indexOf('netscape')!=-1)


var is_nav = (nom.indexOf('netscape')!=-1);


var is_nav4 = (is_nav && (is_major == 4));


var is_mac = (agt.indexOf("mac")!=-1);


var is_gecko = (agt.indexOf('gecko') != -1);


var is_opera = (agt.indexOf("opera") != -1);





var is_rev=0


if (is_gecko) {


temp = agt.split("rv:")


is_rev = parseFloat(temp[1])


}



var frametosearch = self;




function search(whichform, whichframe) {


if (is_ie4up && is_mac) return;


if (is_gecko && (is_rev <1)) return;


if (is_opera) return;


if(whichform.findthis.value!=null && whichform.findthis.value!='') {



str = whichform.findthis.value;


win = whichframe;


var frameval=false;


if(win!=self)


{



frameval=true;


win = parent.frames[whichframe];



}






}



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



var strFound;



if(is_nav4 && (is_minor < 5)) {





strFound=win.find(str); // case insensitive, forward search by default



}



if (is_gecko && (is_rev >= 1)) {





if(frameval!=false) win.focus(); // force search in specified child frame


strFound=win.find(str, false, false, true, false, frameval, false);



// 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: tends to be buggy in Mozilla as of 1.3.1


// (see www.mozilla.org) so is excluded from users


// of that browser.



if (is_not_moz) whichform.findthis.focus();



}



if (is_ie4up) {






if (TRange!=null) {





TestRange=win.document.body.cre ateTextRange();









if (dupeRange.inRange(TestRange)) {



TRange.collapse(false);


strFound=TRange.findText(str);


if (strFound) {


//the following line added by Mike and Susan Keenan, 7 June 2003


win.document.body.scrollTop = win.document.body.scrollTop + TRange.offsetTop;


TRange.select();


}




}





else {



TRange=win.document.body.create TextRange();


TRange.collapse(false);


strFound=TRange.findText(str);


if (strFound) {


//the following line added by Mike and Susan Keenan, 7 June 2003


win.document.body.scrollTop = TRange.offsetTop;


TRange.select();


}





}


}





if (TRange==null || strFound==0) {


TRange=win.document.body.create TextRange();


dupeRange = TRange.duplicate();


strFound=TRange.findText(str);


if (strFound) {


//the following line added by Mike and Susan Keenan, 7 June 2003


win.document.body.scrollTop = TRange.offsetTop;


TRange.select();


}






}



}



if (!strFound) alert ("Bu Sayfada hiç '"+str+"' terimi bulunamadı!")






}


// -->


</script>



<form name="koddostuaramaformu" onSubmit="search(document.koddo stuaramaformu, frametosearch); return false"><input type="text" name="findthis" size="15" title="Kod Dostu Sayfa İçi Arama Formu"> <input type="submit" value="Bu Sayfada Ara" ACCESSKEY="s"></form>



<!--Kod Dostu Sayfa İçi Arama Formu STOP-->