当前位置:萝卜系统下载站 > 技术开发教程 > 详细页面

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

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

更新时间:2022-07-19 文章作者:未知 信息来源:网络 阅读次数:


脚本说明:
第一步:把如下代码加入<body>区域中
<script language = "JavaScript">
var key = "";
function makeEntry ()
{
this.Name="";
this.URL = "";
this.Desc = "";
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];
}
return this;
}

var linksize=0;

namesArray = new makeArray(linksize);
urlsArray = new makeArray(linksize);
descArray = new makeArray(linksize);


var arraycount=0;

<!-- 以下是数据库部分,随意添加和删除-->
arraycount += 1
urlsArray[arraycount] = "http://nettrain.163.net/java/navigation/newscript.htm"
namesArray[arraycount] = "网际快车Java脚本资源站"
descArray[arraycount] = "java javascript applet games activex asp cgi databases search media dw2 midi
music menu html dhtml intranet internet scripts games perl downloads password cookies free graphics
freescripts calander dw2 flash plugins 脚本 密码保护页 脚本 免费资源 主页制作技巧 下载 搜索引擎 表单递交 插
件 教学 动态页面 图形图象 多媒体"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/desktop/adc120.html"
namesArray[arraycount] = "Advanced Disk Catalog v1.20 beta 1"
descArray[arraycount] = "Catalog your disks, folders and files"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/tools/azpr.html"
namesArray[arraycount] = "Advanced ZIP Password Recovery v0.91a"
descArray[arraycount] = "Recover lost password for encrypted ZIP file"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/AdveWith.html"
namesArray[arraycount] = "Adventures With Chickens 2.01"
descArray[arraycount] = "A Christian Windows-95 Arcade/Adventure Game"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/INV58FUL.html"
namesArray[arraycount] = "Alien Invasion 1.0"
descArray[arraycount] = "Action Game for players with disabilities"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/ayatze22.html"
namesArray[arraycount] = "All In One Yahtzee v2.2"
descArray[arraycount] = "Advanced yahtzee game with 5 variations."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/atris_10.html"
namesArray[arraycount] = "Alphatris v1.0"
descArray[arraycount] = "Arcade style word game for windows 95"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/inet/amg32setup.html"
namesArray[arraycount] = "Amigo! v2.2 "
descArray[arraycount] = "Internet Enabled, Free Form PIM"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/32anbj12.html"
namesArray[arraycount] = "Animated Blackjack v1.2"
descArray[arraycount] = "A realistic game with great graphics.."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/95ani12.html"
namesArray[arraycount] = "Animated Slots v1.2"
descArray[arraycount] = "A fun 5 wheel slot machine with great graphics.."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/inet/pie184.html"
namesArray[arraycount] = "ApplePie Pro HTML Editor 1.8.4"
descArray[arraycount] = "Tag highlighting, JavaScript, Homepage Wizard"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/tools/apackmk1.html"
namesArray[arraycount] = "arclab Packager MK1 1.2.0.61"
descArray[arraycount] = "Split one or more files into packages"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/bbsetup.html"
namesArray[arraycount] = "BrainsBreaker 2.1"
descArray[arraycount] = "Create and play jigsaw puzzles in Windows95"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/business/bs1sb.html"
namesArray[arraycount] = "BS1 Small Business v1.1"
descArray[arraycount] = "Bill customers, pay vendors, and manage accounting"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/bubble97.html"
namesArray[arraycount] = "Bubble Puzzle 97 v1.1g"
descArray[arraycount] = "Bubble Puzzle 97 from Conmeg. Bust-a-move clone."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/business/bfsnf216.html"
namesArray[arraycount] = "Budget for Success Win95 v2.16"
descArray[arraycount] = "Budget databases, mortgages, investment planner."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/program/bc10.html"
namesArray[arraycount] = "Bug Collector 1.0"
descArray[arraycount] = "Manage feature requests and problem reports easier."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/games/bzzz_1_01.html"
namesArray[arraycount] = "Bzzz! 1.01"
descArray[arraycount] = "Win95 Game Control a frog to catch flies."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/inet/cachekil.html"
namesArray[arraycount] = "Cache Killer Pro 1.4"
descArray[arraycount] = "Clean up Internet Cache folders"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/business/cal9107b.html"
namesArray[arraycount] = "Calendar+ v1.07.00"
descArray[arraycount] = "Appointment scheduler and to do minder"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/business/cb32.html"
namesArray[arraycount] = "Calendar Builder v2.2b"
descArray[arraycount] = "Quickly and easily make your own custom calendars."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/multi/cdm160.html"
namesArray[arraycount] = "CDMaster v1.6"
descArray[arraycount] = "CDPlayer w/Dubbing and Picture Attachment"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/inet/cgixpert.html"
namesArray[arraycount] = "CGI Expert 3.03"
descArray[arraycount] = "CGI/ISAPI/NSAPI component suite for Delphi and C++"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/tools/clox_5.html"
namesArray[arraycount] = "CLOX v1.3"
descArray[arraycount] = "Gives you world times on your desktop"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/desktop/snow_wi.html"
namesArray[arraycount] = "D2G Snow screen saver v1.00"
descArray[arraycount] = "Displays snow falling on a starry night w/snowman."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/inet/dbQuickPage.html"
namesArray[arraycount] = "dbQuickPage 1.1"
descArray[arraycount] = "Database to HTML conversion for the Web."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/misc/ftrim21.html"
namesArray[arraycount] = "Final Trim v2.1"
descArray[arraycount] = "A Win95 WWII Submarine Multimedia Publication"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/inet/np25.html"
namesArray[arraycount] = "NetPopup 2.51"
descArray[arraycount] = "Messaging tool for Networks"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/inet/nmong144.html"
namesArray[arraycount] = "NewsMonger Search Agent 1.44"
descArray[arraycount] = "Automatically monitor newsgroups for keywords"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/tools/notebk32.html"
namesArray[arraycount] = "Notebook v5.1"
descArray[arraycount] = "Large file text editor."

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/commun/nprsv15.html"
namesArray[arraycount] = "NotePager 1.5"
descArray[arraycount] = "An easy to use alphanumeric paging software"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/multi/ntrack10.html"
namesArray[arraycount] = "n-Track v1.5.2"
descArray[arraycount] = "An audio/MIDI shareware multitrack recorder"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/business/sd20.html"
namesArray[arraycount] = "SecurDesk! 2.0"
descArray[arraycount] = "Security environment and utilities for Win 95/NT"

arraycount += 1
urlsArray[arraycount] = "http://www.win-shareware.com/desktop/yapla16.html"
namesArray[arraycount] = "Yapla V1.6"
descArray[arraycount] = "YAPLA - Yet Another Program Launcher"

linksize = arraycount;

function searchLinks(links, keyword, hits, dirw)
{
var resultcount=0;
<!-- 如下是生成查询结果显示页面!外观自己可以修改相应代码即可! -->
document.write('<HTML>');
document.write('<BODY BGCOLOR=#000000 TEXT=white LINK=yellow VLINK=yellow ALINK=yellow>');
document.write('<CENTER><TABLE BORDER=3 CELLSPACING=0 CELLPADDING=3 BGCOLOR=\"#ff0000
\"><TR><TD><CENTER><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=3 BGCOLOR=\"#42526B\"><TR><TD>');
document.write("<CENTER><font color=red>Results for keywords: </font><font size=5 color=yellow>"
+keyword +"</font></CENTER>");
document.write('</TD></TR></TABLE></CENTER></TD></TR></TABLE></CENTER><P>');
document.write('<OL>');
for (var q=1; q<=links.length; q++)
{
if (links[q].URL.toLowerCase().indexOf(dirw) != -1)
{
if (links[q].Desc.toLowerCase().indexOf(keyword) != -1)
{
resultcount += 1;
if (resultcount > hits)
{
break;
}
else
{
document.write("<LI>");
document.write("<a href=\"" + links[q].URL + "\">" + links[q].Name + "</a>");
document.write(" -" + links[q].Desc + "<br>");
continue;
}
}
if (links[q].Name.toLowerCase().indexOf(keyword) != -1)
{
resultcount += 1;
if (resultcount > hits)
{
break;
}
else
{
document.write("<LI>");
document.write("<a href=\"" + links[q].URL + "\">" + links[q].Name + "</a>");
document.write(" -" + links[q].Desc + "<br>");
continue;
}
}
}
}

}

</script>
<script>
<!-- 如下是表单合法性检查,主要是避免一些非法字符的查询! -->
function validate_form()
{
txt = document.form.search.value;
newindex = document.form.numhits.selectedIndex;
dahits = document.form.numhits[newindex].value;
newindexb = document.form.whichdir.selectedIndex;
dadir = document.form.whichdir[newindexb].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;}
else
{
jsi = new makeLinks(linksize);
searchLinks(jsi, txt, dahits, dadir);
document.write('</OL>');
document.write('<font color=red>....... 查询结果结束 .......</font><P>');
document.write('<hr>');
document.write('</body></html>');
}

}
</script>

<table width=59% border=1 cellpadding=0 cellspacing=0 align=center valign=top>
<tr>
<td width=100% align=left bgcolor=#42526B height="232">
<form name="form">
<center>
<font color="yellow"> </font>
</center>
<center>
<font color="yellow">关键字(小写字符,支持中文):</font> <font color="yellow"><b>
<input name="search" type=text size="20">
</b> </font>
</center>
<font color="yellow"><b><br>
</b> </font>
<center>
<font color="#FFFF00">返回记录数:</font> <font color="yellow"><font face="Arial, Helvetica,
sans-serif">
<select name="numhits" size="1">
<option selected value="25">25
<option value="50">50
<option value="75">75
<option value="100">100
<option value="150">150
<option value="200">200
</select>
</font>检索分类<font face="Arial, Helvetica, sans-serif"> </font><b><font size=3><font size=3>
<select size=1 name="whichdir" class="pt9">
<option selected value="http">ALL
<option value="java">javaScript
<option value="business">Business
<option value="commun">Communications
<option value="desktop">Desktop
<option value="educate">Education
<option value="games">Games
<option value="graphics">Graphics
<option value="hobby">Hobby
<option value="homeuse">Home Use
<option value="inet">Internet
<option value="multi">Multimedia
<option value="program">Programming
<option value="tools">System Tools
</select>
</font></font> </b> </font>
</center>
<font color="yellow"><b><font size=3><font size=3> <br>
<br>
</font></font></b></font><font color=yellow size=3><font color=yellow size=3>
<center>
<font color="yellow"><b>
<input type="button" name="submit" value="Search" onClick="validate_form()">
<input type="reset" name="reset" value=" Clear ">
</b> </font>
</center>
</font></font>
</form>

温馨提示:喜欢本站的话,请收藏一下本站!

本类教程下载

系统下载排行

网站地图xml | 网站地图html