欢迎光临
我们一直在努力

站内搜索脚本例子三(JavaScript)

建站超值云服务器,限时71元/月

脚本说明:

第一步:把如下代码加入<body>区域中

<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://java2000.126.com"

namesarray[arraycount] = "java脚本资源站chinese-gb"

descarray[arraycount] = "java, javascript, scripts, applet, html, dhtml ,activex, midi, search, downloads,

脚本, free, 免费资源"

categoryarray[arraycount] = "最酷的java脚本资源站,大量详细的java源代码和实例说明!"

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] = "richies place"

descarray[arraycount] = "richies place, anime, manga, pictures, pics, movies, links, gif animations,

animation, hentai, java, link"

categoryarray[arraycount] = "richies place! over 30 pages! with a picture gallery, movies, gif

animations, games, java and more."

targetarray[arraycount] = "target=_blank"

linksize = arraycount;

// —-数据库结束 ——

// —-以下是输出结果检索结果的页面代码 —-

function searchlinks(links, keyword){

document.write("<body fontsize=2 bgcolor=#000000 text=#ffffff link=#ccffcc

vlink=#ffffff>")

document.write("搜索关键字结果: <strong>" +keyword +"</strong><br><br>");

for (var q=1; q<=links.length; q++) {

if (links[q].url.tolowercase().indexof(keyword) != -1){

document.write("<a href=" + links[q].url +" " + links[q].target + ">" + links[q].name + "</a> –

");

document.write( links[q].category + "<br><br>");

continue;

}

if (links[q].desc.tolowercase().indexof(keyword) != -1) {

document.write("<a href=" + links[q].url +" " + links[q].target + ">" + links[q].name + "</a> –

");

document.write( links[q].category + "<br><br>");

continue;

}

if (links[q].name.tolowercase().indexof(keyword) != -1) {

document.write("<a href=" + links[q].url +" " + links[q].target + ">" + links[q].name + "</a> –

");

document.write( links[q].category + "<br><br>");

continue;

}

}

}

</script>

<font size="5" color="#ff0000">站内搜索引擎<br>

</font><font color="#ff0000"> <font color="#000000">测试:输入关键字"java"

或中文字符"免费" 查询。</font></font> </div>

<p align=center>

<form name="form">

<div align="center">

<p>查询关键字:

<input type="text" size=20 name="search">

<input type="button" name="submit" value="开始查询" onclick="validate_form()" class="pt9">

<input type="reset" name="reset" value="清除" class="pt9">

<br>

</p>

</div>

</form>

<!– 以下是合法性检测 –>

<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("<hr>");

document.write("<a href=searchabledb2.htm>返回检索页</a><br><br> ");

//将searchabledb2.htm替换为检索页的url,以便访问者返回检索页。

}

}

</script>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 站内搜索脚本例子三(JavaScript)
分享到: 更多 (0)