要完成此效果把如下代碼加入到區(qū)域中
<script language="javascript">
var key = "";
function makeEntry (){
this.Name="";
this.URL = "";
this.Desc = "";
this.Category = "";
this.Target = "";
return this;
}
function makeArray(n) {
this.length = n;
for (var k = 1; k <= n; k++) {
this[k] = "";
}
return this;
}
function makeLinks(size) {
this.length = size;
for (var r=1; r<= size; r++) {
this[r] = new makeEntry();
this[r].Name = namesArray[r];
this[r].URL = urlsArray[r];
this[r].Desc = descArray[r];
this[r].Category = categoryArray[r];
this[r].Target = targetArray[r];
}
return this;
}
var linksize=0
datesArray = new makeArray(linksize);
namesArray = new makeArray(linksize);
urlsArray = new makeArray(linksize);
descArray = new makeArray(linksize);
categoryArray = new makeArray(linksize);
targetArray = new makeArray(linksize);
var arraycount=0
arraycount += 1
urlsArray[arraycount] = "http://typhoon.500.to"
namesArray[arraycount] = "JavaScript Fairyland"
descArray[arraycount] = "java, javascript, scripts, applet, html, dhtml ,activex, midi, search,
downloads, 腳本, free, 免費(fèi)資源"
categoryArray[arraycount] = "大量詳細(xì)的javascript源代碼和實(shí)例說(shuō)明!"
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://members.aol.com/MASTER54X/Anime.html"
namesArray[arraycount] = "Anime Master"
descArray[arraycount] = "anime master, anime, project a-ko, vampire hunter D, tenchi muyo,
bubblegum crisis, sailor moon, sailormoon, gunsmith cats, slayers, all purpose cultural cat girl
nuku nuku, plastic little, devil hunter yohko, iria: zeiram the animation, iria, ranma 1/2,
ranma, fist of the north star, multimedia, galleries, pic galleries, picture gallery, image
gallery, image galleries"
categoryArray[arraycount] = "Multimedia, Image galleries for project a-ko, vampire hunter D,
tenchi muyo, bubblegum crisis, sailormoon, gunsmith cats, slayers, all purpose cultural cat girl
nuku nuku, plastic little, devil hunter yohko, iria: zeiram the animation, ranma 1/2, and fist
of the north star."
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://www.geocities.com/Tokyo/Towers/6508/"
namesArray[arraycount] = "The Anime Shrine"
descArray[arraycount] = "the anime shrine, anime shrine, anime, the anime shrine, anime shrine,
manga, saintseiya, fushigiyuugi, fushigi yuugi, evangelion, neon genesis evangelion, eva, ranma,
ranma 1/2"
categoryArray[arraycount] = "this is a fairly large site with large image galleries from many dif
animes, many links, gives out awards, has 3 voting shrines, also sub-Shrines for Fushigi Yuugi,
SaintSeiya, Evangelion, and Ranma 1/2. And much more! Must see!"
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://home.taegu.net/~virus/"
namesArray[arraycount] = "Evangelion Site"
descArray[arraycount] = "evangelion site, anime, evangelion, neon genesis, neon genesis
evangelion, eva, neon, genesis"
categoryArray[arraycount] = "This site is about evangelion, but available in Korean only..."
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://animeonline.org/"
namesArray[arraycount] = "The Animeonline Network"
descArray[arraycount] = "the animeonline network, anime, animecca, news, information, anime
magazine, magazine, zine, e-zine"
categoryArray[arraycount] = "Your Online Anime Magazine!"
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://www.visi.com/~vdgaijin/gaijin.html"
namesArray[arraycount] = "Psychommu Gaijin Anime E-zine"
descArray[arraycount] = "psychommu gaijin anime e-zine, anime, music, links, news, information,
e-zine, zine"
categoryArray[arraycount] = "Our aim is to provide you with news and information on some of the
coolest aspects of Anime. Old and new! So come on in and enjoy!"
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://the.animearchive.org/"
namesArray[arraycount] = "Ultimate Animanga Archive"
descArray[arraycount] = "ultimate animanga archive, anime, manga, images, pictures, image
gallery, midi, image galleries, music, chat, information, descriptions, info"
categoryArray[arraycount] = "Searchable page of images, info, and descriptions of anime OAVs and
series."
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://otakuworld.com/"
namesArray[arraycount] = "Otaku World"
descArray[arraycount] = "otaku world, anime, manga, desktop themes, anime themes, search engine,
link database, web rings, web ring"
categoryArray[arraycount] = "One of the largest multimedia anime sources on the web!"
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://www.usagi.com"
namesArray[arraycount] = "Usagi.com"
descArray[arraycount] = "usagi.com, anime, manga, links, link, database, tenchi, tenchi muyo,
download, multimedia"
categoryArray[arraycount] = "Your guide to the online anime community!"
targetArray[arraycount] = "target=_blank"
arraycount += 1
urlsArray[arraycount] = "http://www.si.hhs.nl/~v962343/home.html"
namesArray[arraycount] = "Richie's Place"
descArray[arraycount] = "richie's place, anime, manga, pictures, pics, movies, links, gif
animations, animation, hentai, java, link"
categoryArray[arraycount] = "Richie's Place! Over 30 pages! with a picture gallery, movies, gif
animations, games, java and more."
targetArray[arraycount] = "target=_blank"
linksize = arraycount;
// ----數(shù)據(jù)庫(kù)結(jié)束 ------
// ----以下是輸出結(jié)果檢索結(jié)果的頁(yè)面代碼 ----
function searchLinks(links, keyword){
document.write("")
document.write("搜索關(guān)鍵字結(jié)果:
" +keyword +"");
for (var q=1; q<=links.length; q++) {
if (links[q].URL.toLowerCase().indexOf(keyword) != -1){
document.write("
" + links[q].Name +
" - ");
document.write( links[q].Category + "
");
continue;
}
if (links[q].Desc.toLowerCase().indexOf(keyword) != -1) {
document.write("
" + links[q].Name +
" - ");
document.write( links[q].Category + "
");
continue;
}
if (links[q].Name.toLowerCase().indexOf(keyword) != -1) {
document.write("
" + links[q].Name +
" - ");
document.write( links[q].Category + "
");
continue;
}
}
}
</script>
站內(nèi)搜索引擎
測(cè)試:輸入關(guān)鍵字"java"
或中文字符"免費(fèi)" 查詢。
<script>
function validate_form() {
txt = document.form.search.value;
if (txt.indexOf(".") != -1){
alert("Search is invalid! Contains a '.'"); return;}
if (txt.indexOf(",") != -1){
alert("Search is invalid! Contains a ','"); return;}
if (txt.indexOf("@") != -1){
alert("Search is invalid! Contains a '@''"); return;}
if (txt.indexOf("!") != -1){
alert("Search is invalid! Contains a '!''"); return;}
if (txt.indexOf("#") != -1){
alert("Search is invalid! Contains a '#''"); return;}
if (txt.indexOf("$") != -1){
alert("Search is invalid! Contains a '$''"); return;}
if (txt.indexOf("%") != -1){
alert("Search is invalid! Contains a '%''"); return;}
if (txt.indexOf("^") != -1){
alert("Search is invalid! Contains a '^''"); return;}
if (txt.indexOf("&") != -1){
alert("Search is invalid! Contains a '&''"); return;}
if (txt.indexOf("*") != -1){
alert("Search is invalid! Contains a '*''"); return;}
if (txt.indexOf("(") != -1){
alert("Search is invalid! Contains a '(''"); return;}
if (txt.indexOf(")") != -1){
alert("Search is invalid! Contains a ')''"); return;}
if (txt.indexOf("[") != -1){
alert("Search is invalid! Contains a '[''"); return;}
if (txt.indexOf("]") != -1){
alert("Search is invalid! Contains a ']''"); return;}
if (txt.indexOf(";") != -1){
alert("Search is invalid! Contains a ';''"); return;}
if (txt.indexOf(":") != -1){
alert("Search is invalid! Contains a ':''"); return;}
if (txt.indexOf("<") != -1){
alert("Search is invalid! Contains a '<''"); return;}
if (txt.indexOf(">") != -1){
alert("Search is invalid! Contains a '>''"); return;}
if (txt.indexOf("?") != -1){
alert("Search is invalid! Contains a '?''"); return;}
if (txt.indexOf("-") != -1){
alert("Search is invalid! Contains a '-''"); return;}
if (txt.indexOf("=") != -1){
alert("Search is invalid! Contains a '=''"); return;}
if (txt.indexOf("+") != -1){
alert("Search is invalid! Contains a '+''"); return;}
else {
jsi = new makeLinks(linksize);
searchLinks(jsi, txt);
document.write("
");
//將searchabledb2.htm替換為檢索頁(yè)的URL,以便訪問(wèn)者返回檢索頁(yè)。
}
}
</script>