Vous êtes sur la page 1sur 15

Search site - Exemplu 1

<SCRIPT language=JavaScript> var NS4 = (document.layers); var IE4 = (document.all); var win = window; var n = 0; function findInPage(str) { var txt, i, found; if (str == "") return false; if (NS4) { if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; if (n == 0) alert("Not found."); } if (IE4) { txt = win.document.body.createTextRange(); for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit");

} if (found) { txt.moveStart("character", -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } else { if (n > 0) { n = 0; findInPage(str); } else alert("Sorry, we couldn't find.Try again"); } } return false; } </SCRIPT>

<FORM name=search onsubmit="return findInPage(this.string.value);"> <P align=center><FONT size=3> <INPUT style="BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; FONT-SIZE: 8pt; BORDERLEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid"

onchange="n = 0;" size=16 name=string></FONT><BR><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #aaaaaa" type=submit value=Search in page ><center><font size=2pt;><font family=Times New Roman;><b>

<font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>

<BR> </P></FORM></DIV><BR><!-- /Search-->

Search site - Exemplu 2

<div class="searchbox"> <form action="http://localhost:65489/WebSiteDecoratiuniInterioare/AmenajariBai.aspx" method="get" class="search" id="f.search"> <input type="hidden" name="stoken" value="1A813A3C"><input type="hidden" name="force_sid" value=""> <input type="hidden" name="lang" value="2"> <input type="hidden" name="cl" value="search"> <input type="text" name="searchparam" value="" size="21" id="f.search.param" class="txt"> <select id="test_searchCategorySelect" class="search_input" name="searchcnid" > <option value=""> - toate categoriile - </option> <option value="c8ffd22e0ad54d1f1b1fc32365f9e0a8">SLIMMING SOLUTIONS</option> <option value="f272f93b6eb33305206eabe4ba2741ca">- Reglarea poftei de mancare</option> <option value="f27520a6a373b60729b7d313bc277fd6">- Detoxifiere</option> <option value="f273f96821ae9d18c4eb0be514247a6d">- Neutralizarea grasimilor si zaharurilor</option>

<option value="9184cb9feaa1399da5847f29c9023471">- Bauturi cu puteri de ardere</option> <option value="918fd6af537bd652550647ff1a1ecc6b">- Silueta si Frumusete</option> <option value="9182f5724d9ef401a6db5fe3af356e34">- Top 3 produse de detoxifiere</option> <option value="918972424ea51e588058adffc4ff4803">- Top 3 produse de slabire</option> <option value="918ad10cea6f6a1f7e635118849914cb">- SUPLIMENTE DE SANATATE</option> <option value="0921a602c6f1654530393f8d3fbbcdc9">-- Vitalitate si imunitate</option> <option value="0928d1b9b1d3300118f32cce7810bfdd">-- Articulatii si dureri</option> <option value="092756fb69e3f067e9b7c0e7c42145c4">-- Digestie si hepatobiliare</option> <option value="092ed50702f0945c248d9fe8fdc812a3">-- Inima si diabet</option> <option value="092b85224e98b8f8ed41fa5c2286a0dd">-- Sanatate la masculin</option> <option value="09221093bf3ba1ea7d8e53db8b8fd5bd">-- Sanatate la feminin</option> <option value="fdfa3a529496d961e719fbe97df7bc55">-- GHIDURI PRACTICE</option> </select>

&nbsp; <span class="btn"><input id="test_searchGo" type="submit" class="btn" value="GO!"></span> </form> <strong class="h2 search">Cautare produse:&nbsp;</strong> </div>

Search site - Exemplu 3

<form name="jksearch" action="http://www.google.com/search" method="get" onSubmit="jksitesearch(this)">

<p>Search JavaScript Kit:<br /> <input id="hiddenquery" type="hidden" name="q" /> <input name="qfront" type="text" style="width: 200px" value="navigator object" /> <input type="submit" value="Search" /><br />

<div style="font: bold 11px Verdana;">Google:<input name="se" type="radio" checked> Yahoo:<input name="se" type="radio"> MSN:<input name="se" type="radio"> </div>

<script type="text/javascript">

// All-in-one Internal Site Search script- By JavaScriptKit.com (http://www.javascriptkit.com) // For this and over 400+ free scripts, visit JavaScript Kithttp://www.javascriptkit.com/ // This notice must stay intact for use

//Enter domain of site to search. var domainroot="www.javascriptkit.com"

var searchaction=[ //form action for the 3 search engines "http://www.google.com/search", "http://search.yahoo.com/search", "http://search.msn.com/results.aspx" ]

var queryfieldname=["q","p","q"] //name of hidden query form for the 3 search engines

function switchaction(cur, index){ cur.form.action=searchaction[index] document.getElementById("hiddenquery").name=queryfieldname[index] }

function jksitesearch(curobj){

for (i=0; i< document.jksearch.se.length; i++){ //loop through radio to see which is checked if (document.jksearch.se[i].checked==true) switchaction(document.jksearch.se[i], i) } document.getElementById("hiddenquery").value="site:"+domainroot+" "+curobj.qfront.value }

</script>

</p>

</form>

<p style="font: normal 11px Arial">This free script provided by<br /> <a href="http://www.javascriptkit.com">JavaScript Kit</a></p>

Search site - Exemplu 4

The JavaScript for the above is quite easy. However, to understand it, you might need to check out the information on normal drop-down menus., and check out stuff in the HTML tutorial and elsewhere in this tutorial. Here is the code in the HEAD of the document:
<script type="text/javascript"> <!--//

function nullOptions(aMenu){

tot=aMenu.options.length;

if (aMenu.options.length>0) for (i=0;i<tot;i++) {


aMenu.options[i]=null } aMenu.options.length=0; } function MySearchF(){ nullOptions(document.F187.MySelect); URLs=new Array() titls=new Array() Kwds=new Array() URLs[0]="alertConfirm.htm"; titls[0]="CONFIRM MESSAGE BOXES"; Kwds[0]="HTML, JAVASCRIPT, TUTORIAL, LESSONS, GUIDE, CHOICES IN MESSAGE BOXES, CONFIRM, ALERTS,IF,LOCATION,CONFIRM,"; /* ..... There are a lot of URLs, Keywords, Titles so I have just included the first set for one page */

var joined=new Array()


/* We start off a new array by joining together the titles and keywords */

/* ####################### Only the data above needs to be changed ####################### */

var joined=new Array()


{ for (i=0;i<URLs.length; i++){ joined[i]=titls[i]+Kwds[i]

}
Searchphrase=document.F187.MyText.value j=0; checker=0;

if (document.F187.MyText.value.length<1){
alert('Please enter something to search for.'); } else { var myFoundURL=new Array();

var myFoundText=new Array(); for (i=0;i<URLs.length; i++)


{ if (joined[i].indexOf(Searchphrase.toUpperCase())>-1){ checker+=1;

j++; myFoundURL[j]=URLs[i]; myFoundText[j]=titls[i]; } } if (checker>0){ document.F187.MySelect.options[0]=new Option('Results: '+checker,'')

for (j=1;j<checker+1;j++) {
document.F187.MySelect.options[j]=

new Option(myFoundText[j],myFoundURL[j]);
} } else { document.F187.MySelect.options[0]=new Option('Sorry! Couldn\'t find anything:','')

} } }
//Older Netscapes like a refresh, but Microsoft doesn't and nor does Net 7 /*if (navigator.appName.indexOf("Netscape")>-1)

history.go(0)*/

}
//--> </script> <script type="text/javascript"> <!--//

function searchGo(){
if (document.F187.MySelect.selectedIndex>0){ location=document.F187.MySelect.options[document.F187.MySelect.selectedIndex]. value } else { alert('Please select an option.')

} }
//--> </script> <!-- ####################### stop copying script here ####################### -->

On mouse over
<html> <head> <script type="text/javascript"> function writeText(txt) { document.getElementById("desc").innerHTML=txt; } </script> </head>

<body> <img src ="planets.gif" width ="145" height ="126" alt="Planets" usemap="#planetmap" />

<map name="planetmap"> <area shape ="rect" coords ="0,0,82,126" onmouseover="writeText('The Sun and the gas giant planets like Jupiter are by far the largest objects in our Solar System.')" href ="sun.htm" target ="_blank" alt="Sun" />

<area shape ="circle" coords ="90,58,3" onmouseover="writeText('The planet Mercury is very difficult to study from the Earth because it is always so close to the Sun.')" href ="mercur.htm" target ="_blank" alt="Mercury" />

<area shape ="circle" coords ="124,58,8" onmouseover="writeText('Until the 1960s, Venus was often considered a twin sister to the Earth because Venus is the nearest planet to us, and because the two planets seem to share many characteristics.')" href ="venus.htm" target ="_blank" alt="Venus" /> </map>

<p id="desc">Mouse over the sun and the planets and see the different descriptions.</p>

</body> </html>

Show time

<html> <head> <script type="text/javascript"> function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('txt').innerHTML=h+":"+m+":"+s; t=setTimeout('startTime()',500); }

function checkTime(i) { if (i<10) { i="0" + i; } return i;

} </script> </head>

<body onload="startTime()"> <div id="txt"></div> </body> </html>