腳本說明:將以下程式碼加入區域中 <br/>var key = "";<p><br/><p>function makeEntry (){<br/><br/> = " .Name="";<br/>this.URL = "";<br/>this.Desc = "";<br/> this.Category = "";<br/>return this;<br/>}<p>function makeArray(n) {<br/>.thislength = nakeArray(n) {<br/>.this.this. ;<br/>for (var k = 1; k <= n; k++) {<br/>this[k] = "";<br/>}<br/>回傳這個;}<p><br/>function makeLinks(size) {<br/>this.length = size;<br/> for (var r=1; r<= size; r++) {<br/>this[r] = new makeEntry();<br/>this[r].Date =datesArray[r];<br/>this[r].Name = namesArray[r ];<br/>this[r].URL = urlsArray[r];<br/>this[r].Desc = descArray[r];<br/>}<br/>回傳這個;}<p><br/>var linkssize=0<p>}<br/><br/><br/>var linkssize=0 linksize);<p>namesArray = new makeArray(linksize);<br/>urlsArray = new makeArray(linksize); descArray = new makeArray(linksize);<p><br/><br/>var arraycount=0<br/><br/><br/>arraycount += 1 <br/>datesArray[arraycount] = "5/30/2000"urlsArray[arraycount] = "http://www.163. net"<p>namesArray[arraycount] = "網易"<br/>descArray[arraycount] = "163 網易Yeah 126 中文"/alert" (arraycount)<br/><br/>arraycount += 1 <br/>datesArray[arraycount] = "5/30/2000 " <br/>urlsArray[arraycount] = "http://www.sina.com.cn"namesArray[arraycount] = "http://www.sina.com.cn"<p>namesArray[arraycount] = "http://www.sina.com.cn"<br/>namesArray[arraycount] = "新浪網"<br/>descArray[arraycount] = "新浪網聊天聊天新聞超級"<br/>//alert(arraycount) <br/><br/>arraycount += 1 datesArray[arraycount] = "5/30/2000"<p>urlcounts =[arraycount] "httparraycount] //www.sohu.com"namesArray[arraycount] = "搜狐"<p>descArray[arraycount] = "搜狐網聊天新聞"//alert(arraycount)<p><br/>linksize = arraycount;<br/><br/>//----結束資料------<br/>function showAll(linkobj) {<p>for (var s =1; s<= linkobj.length; s++) {<br/>showLink(linkobj,s);<br/>}<br/>}<br/><br/>ftion ftions (links, index) {<p>//document.write("<表格邊框>");<br/>document.write("<tr> ;<td>" + links[index].Date +"") ;document.write("<td><a href="http://www.php1.cn/" >document.write("<td>" + links[index].Desc + "< /tr>");<p>//document.write(""); <br/>}<br/><br/>function searchLinks(links, keywords){<br/>document.write("搜尋結果: " +keyword +"<br> ");<br/><br/>document.write("<表格邊框>");<br/>for (var q=1; q<=links.length; q++) {<br/>//document.write(q+".")<br/>if ( links[q].URL.indexOf(keyword) != -1){<br/>/ / document.write("關鍵字搜尋結果: "+keyword+ "<br>" +links[q].Name +"<p> ")<br/>//document.write("搜尋結果: "+keyword+ " <br>" );<br/>showLink(links,q);<br/>繼續;<br/>}<br/>if (links[q].Desc.indexOf(keyword) != -1) {<br/>showLink(links,q);<br/>繼續;<br/>}<br/>if (links[q].Date.indexOf(keyword) != -1) {<br/>showLink(links,q);<br/>繼續; <br/>}<br/>if (links[q].Name.indexOf(keyword) != -1) {showLink(links,q);<p>continue;<br/>}<br/>}document.write(""); <p>}<br/><br/><br/>//最後的東西<br/>//主程式---<br/>jsi = new makeLinks(linksize);<p>document.write("<title>站內查詢");<br/>searchument.write("<title>站內查詢");<br/>searchs( ,prompt("輸入查詢關鍵字:","輸入查詢關鍵字:"));<br/>document.write("<hr>");document.write("按<b>再次搜尋再次查詢<hr>");<p>document. write("<form><input type=button onClick='history.go(0)' value='再搜尋'>");<p>//顯示所有連結// document.write("<table border>");<p>//showAll(jsi);<br/>//document.write("");🎜; 🎜🎜 以上就是站內搜尋腳本範例二(javascript)_Javascript教學的內容,更多相關內容請關注PHP中文網(m.sbmmt.com)! 🎜🎜🎜🎜