腳本說明:第一步:把如下程式碼加入區域中<br/>var key = "";<br/>function makeEntry (){<br/>this.Name="" ;<br/>this .URL = "";<br/>this.Desc = "";<br/>this.Category = "";<br/>this.Target = "";<br/>回傳這個;<br/>}<p><br/><p>function makeArray( length = n;<br/>for (var k = 1; k <= n; k++) {<br/>this[k] = "";<br/>}<br/>return this;<br/>}<br/>function makeLinks(size) {<p>}<br/><br/>function makeLinks(size) {<br/> this. size;<br/>for (var r=1; r<= size; r++) {<br/>this[r] = new makeEntry();<br/>this[r].Name = namesArray[r];<br/>this[r ].URL = urlsArray[r];<br/>this[r].Desc = descArray[r];<br/>this[r].Category = CategoryArray[r];<br/>this[r].Target = targetArray[r];<br/>} this[r].Target = targetArray[r];<p>} <br/>this[r].Target = targetArray[r];}<p>返回這個; <br/>}<br/><br/><br/>var linkssize=0<br/>datesArray = new makeArray(linksize);<p>namesArray = new makeArray(linksize); = new makeArray(linksize);<br/>targetArray = new makeArray(linksize);<p><br/>var arraycount=0<br/><br/><!-- 資料庫部分由此開始--><br/>arraycount += 1 <br/><!-- 資料庫部分由此開始--><br/>arraycount += 1 <br/>url /java2000.126.com"namesArray[arraycount] = "java腳本資源站Chinese-GB"<p>descArray[arraycount] = "java, javascript, scripts, applet, html, dhtml ,activex, midi , javascript, scripts, applet, html, dhtml ,activex, midi , 搜尋, 下載, <br/>腳本, 免費, 免費資源"<br/>categoryArray[arraycount] = "最酷的java腳本資源站,大量詳細的java原始碼和實例說明!"<br/>targetArray[arraycount] = "target=_blank" <br/><br/>arraycount += 1 <br/>urlsArray[arraycount] = "http://members.aol.com/MASTER54X/Anime.html"<br/>namesArray[arraycount] = "動畫大師"<br/>descArray[arraycount] = "動畫大師,動漫、project a-ko、<br/>descArray[arraycount] = "動畫大師,動漫、project a-ko、<br/>descArray[arraycount] = "動漫大師,動漫、project a-ko、descArray[arraycount] = "動畫大師,動漫、project a-ko、吸血鬼獵人D、tenchi muyo、bubblegum <p>crisis、美少女戰士、水手月亮、槍匠貓、殺手、萬能文化貓女nuku nuku、塑膠<br/>little、惡魔獵人yohko、iria:zeiram 動畫、iria 、亂馬1/ 2、亂馬、北極星之拳、<br/>多媒體、圖庫、圖片庫、圖片庫、圖片庫、圖片庫"<br/>categoryArray[arraycount] = "多媒體、a-ko 專案的圖片庫、吸血鬼獵人D、天地無用、 <br/>泡泡糖危機、水手月、槍匠貓、殺手、萬能文化貓女努庫努庫、塑膠<br/>小、惡魔獵人洋子、艾莉亞:澤拉姆動畫、亂馬1/2、北極星之拳。 "<br/>targetArray[arraycount] = "target=_blank"<br/><br/>arraycount += 1 urlsArray[arraycount] = "http://www.geocities.com/Tokyo/Towers/6508/"<p>namesArray[arraycount]神社"<br/>descArray[arraycount] = "動畫神社, 動畫神社, 動畫, 動畫神社, 動畫神社, 漫畫, <br/>saintseiya, fushigiyuugi, fushigi yuugi, 新世紀福音戰士, 新世紀福音戰士, eva, 亂馬, 亂馬1/2 "<br/>categoryArray[arraycount] = "這是一個相當大的網站,擁有來自許多不同動畫的大型圖片庫,<br/>許多鏈接,頒發獎項,有3 個投票神社,還有Fushigi Yuugi、SaintSeiya、<br/> Evangelion 和亂馬1/2。還有更多!一定要看! "<br/>targetArray[arraycount] = "target=_blank"<p>arraycount += 1 <br/>urlsArray[arraycount] = "http://home.taegu.net/~virus/"<br/>namesArray[arraycount] = "新世紀福音戰士Site"<br/>descArray[arraycount] = "新世紀福音戰士網站, Anime, evangelion, neon genesis, neon genesis evangelion, eva, <br/>neon, genesis"<br/>categoryArray[arraycount] = "<br/>neon, genesis"categoryArray[arraycount] = "<p>neon, genesis"<br/>categoryArray[arraycount] = "此福音戰士網站是關於新世紀福音戰士的但僅提供韓文版本.. ."<br/>targetArray[arraycount] = "target=_blank"<br/><br/>arraycount += 1 <br/>urlsArray[arraycount] = "http://animeonline.org/"<br/>namesArray[arraycount] = "Thearraycount] = "Thearraycount] = "Thearraycount] = "Thearraycount] = "Thearraycount] = "Thearray一樣Animeonline Network"<br/>descArray[arraycount ] = "animeonline 網路、動漫、animecca、新聞、資訊、動漫雜誌、雜誌、雜誌、電子雜誌"🎜categoryArray[arraycount] = "您的線上動漫雜誌! "🎜targetArray[arraycount] = "target=_blank "🎜🎜arraycount += 1 🎜urlsArray[arraycount] = "http://www.visi.com/~vdgaijin/gaijin.html"🎜namesArray[arraycount]~vdgaijin/gaijin.html"🎜namesArray[ Gaijin 動畫電子雜誌"🎜descArray[arraycount] =「psychommu gaijin 動漫電子雜誌、動漫、音樂、連結、新聞、資訊、電子雜誌、🎜zine」🎜categoryArray[arraycount] =「我們的目標是為您提供一些最酷🎜方面的新聞和資訊動漫。又舊又新!所以快來享受吧! ”🎜targetArray[arraycount] = "target=_blank"🎜<p>arraycount += 1 <br/>urlsArray[arraycount] = "http://the.animearchive.org/"<br/>namesArray[arraycount] = "Ultimate Animanga Archive"<br/>descArray[arraycount] = "ultimate animanga archive, anime, manga, images, pictures, image gallery, midi, <br/>image galleries, music, chat, information, descriptions, info"<br/>categoryArray[arraycount] = "Searchable page of images, info, and descriptions of anime OAVs and series."<br/>targetArray[arraycount] = "target=_blank"<p>arraycount += 1 <br/>urlsArray[arraycount] = "http://otakuworld.com/"<br/>namesArray[arraycount] = "Otaku World"<br/>descArray[arraycount] = "otaku world, anime, manga, desktop themes, anime themes, search engine, link <br/>database, web rings, web ring"<br/>categoryArray[arraycount] = "One of the largest multimedia anime sources on the web!"<br/>targetArray[arraycount] = "target=_blank"<p>arraycount += 1 <br/>urlsArray[arraycount] = "http://www.usagi.com"<br/>namesArray[arraycount] = "Usagi.com"<br/>descArray[arraycount] = "usagi.com, anime, manga, links, link, database, tenchi, tenchi muyo, download, <br/>multimedia"<br/>categoryArray[arraycount] = "Your guide to the online anime community!"<br/>targetArray[arraycount] = "target=_blank"<p>arraycount += 1 <br/>urlsArray[arraycount] = "http://www.si.hhs.nl/~v962343/home.html"<br/>namesArray[arraycount] = "Richie's Place"<br/>descArray[arraycount] = "richie's place, anime, manga, pictures, pics, movies, links, gif animations, <br/>animation, hentai, java, link"<br/>categoryArray[arraycount] = "Richie's Place! Over 30 pages! with a picture gallery, movies, gif <br/>animations, games, java and more."<br/>targetArray[arraycount] = "target=_blank"<p>linksize = arraycount;<p>// ----数据库结束 ------<br/>// ----以下是输出结果检索结果的页面代码 ----<p>function searchLinks(links, keyword){<br/>document.write("<BODY fontsize='2' BGCOLOR='#000000' TEXT='#ffffff' LINK='#ccffcc' <br/>VLINK='#ffffff'>")<br/>document.write("搜索关键字结果: <strong>" +keyword +"</strong><br><br>");<br/>for (var q=1; q<=links.length; q++) {</p><p>if (links[q].URL.toLowerCase().indexOf(keyword) != -1){<br/>document.write("<a href="http://www.php1.cn/">");<br/><br/>document.write( links[q].Category + "<br><br>");<br/>continue;<br/>}<br/>if (links[q].Desc.toLowerCase().indexOf(keyword) != -1) {<br/>document.write("<a href="http://www.php1.cn/">");<br/><br/>document.write( links[q].Category + "<br><br>");<br/>continue;<br/>}<br/>if (links[q].Name.toLowerCase().indexOf(keyword) != -1) {<br/>document.write("<a href="http://www.php1.cn/">");<br/><br/>document.write( links[q].Category + "<br><br>");<br/>continue;<br/>}<p>}<p><br/>}<p>站内搜索引擎 测试:输入关键字"java" 或中文字符"免费" 查询。 查询关键字: <br/>function validate_form() {<p>txt = document.form.search.value;<br/>if (txt. indexOftxt". ") != -1){<br/>alert("搜尋無效!包含'.'"); return;}<br/>if (txt.indexOf(",") != -1){<br/>alert("搜尋無效!包含','"); return;}<br/>if (txt.indexOf("@") != -1){<br/>alert("搜尋無效!包含'@''"); return;}<br/>if (txt.indexOf ("!") != -1){<br/>alert("搜尋無效!包含'!''"); return;}<br/>if (txt.indexOf("#") != -1){<br/>alert("搜尋無效! if (txt.indexOf("%") != -1){<br/>alert("搜尋無效!包含'%''"); return;}<br/>if (txt.indexOf("^") != -1) {<br/>alert("搜尋無效!包含'^''"); return;}<br/>if (txt.indexOf("&") != -1){<br/>alert("搜尋無效!包含'&''") ; return;}<br/>if (txt.indexOf("*") != -1){<br/>alert("搜尋無效!包含'*''"); return;}<br/>if (txt.indexOf("(") != -1){<br/>alert("搜尋無效!包含'(''"); return;}<br/>if (txt.indexOf(")" ) != -1){<br/>alert("搜尋無效!包含' )''"); return;}<br/>if (txt.indexOf("[") != -1){<br/>alert("搜尋無效!包含'[''"); return;}<br/>if (txt.indexOf ("]") != -1){<br/>alert("搜尋無效!包含']''"); return;}<br/>if (txt.indexOf(";") != -1){<br/>alert("搜尋無效!包含':''"); return;}<br/>if (txt.indexOf("<") != -1){<br/>alert("搜尋無效!包含'<''"); return;}<br/>if (txt .indexOf(">") != -1){<br/>alert("搜尋無效!包含'>''"); return;}<br/>if (txt.indexOf("?") != -1){<br/>alert ("搜尋無效!包含'?''"); return;}<br/>if (txt.indexOf("-") != -1){<br/>alert("搜尋無效!包含'-''"); return; }<br/>if (txt.indexOf("=") != -1){<br/>alert("搜尋無效!包含'=''"); return;}<br/>if (txt.indexOf("+") != - 1){<br/>alert("搜尋無效!包含'+''"); return;}<br/>else {<br/>jsi = new makeLinks(linksize);<br/>searchLinks(jsi, txt);<br/>document.write("<hr> ");<br/>document.write("<a href="http: //www.php1.cn/">//將searchabledb2.htm替換為搜尋頁的URL,方便訪客返回搜尋頁。<br/>}<br/><br/> }<br/> 以上就是站內搜尋腳本範例三(javascript)_Javascript教學的內容,更多相關內容請關注PHP中文網(m.sbmmt.com)!