最新动态
站内搜索脚本例子二(JavaScript)
2024-12-25 04:22
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

脚本说明:
把如下代码加入<body>区域中
<script language="javascript">
var key = "";

function makeentry (){
this.date = "";

站内搜索脚本例子二(Javas<em></em>cript)


this.name="";
this.url = "";
this.desc = "";
this.category = "";
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].date = datesarray[r];
this[r].name = namesarray[r];
this[r].url = urlsarray[r];
this[r].desc = descarray[r];
}
return this;
}


var linksize=0

datesarray = new makearray(linksize);
namesarray = new makearray(linksize);
urlsarray = new makearray(linksize);
descarray = new makearray(linksize);


var arraycount=0


arraycount += 1
datesarray[arraycount] = "5/30/2000"
urlsarray[arraycount] = "http://www.163.net"
namesarray[arraycount] = "网易"
descarray[arraycount] = "163 netease yeah 126 chinese "
//alert(arraycount)

arraycount += 1
datesarray[arraycount] = "5/30/2000 "
urlsarray[arraycount] = "http://www.sina.com.cn"
namesarray[arraycount] = "新浪网"
descarray[arraycount] = "sina net chat chatting news super"
//alert(arraycount)

arraycount += 1
datesarray[arraycount] = "5/30/2000 "
urlsarray[arraycount] = "http://www.sohu.com"
namesarray[arraycount] = "搜狐"
descarray[arraycount] = "sohu net chat news "
//alert(arraycount)

linksize = arraycount;

// ----end data -------

function showall(linkobj) {
for (var s=1; s<= linkobj.length; s++) {
showlink(linkobj,s);
}
}

function showlink (links, index) {
//document.write("<table border>");
document.write("<tr><td>" + links[index].date +"</td>");
document.write("<td><a href=" + links[index].url +">" + links[index].name + "</a></td>");
document.write("<td>" + links[index].desc + "</td></tr>");
//document.write("</table>");
}

function searchlinks(links, keyword){
document.write("搜寻结果: " +keyword +"<br>");

document.write("<table border>");
for (var q=1; q<=links.length; q++) {
//document.write(q+".")
if (links[q].url.indexof(keyword) != -1){
// document.write("search results for keyword: "+keyword+ "<br>" +links[q].name +"<p>")
//document.write("搜寻结果: "+keyword+ "<br>" );
showlink(links,q);
continue;
}
if (links[q].desc.indexof(keyword) != -1) {
showlink(links,q);
continue;
}
if (links[q].date.indexof(keyword) != -1) {
showlink(links,q);
continue;
}
if (links[q].name.indexof(keyword) != -1) {
showlink(links,q);
continue;
}
}
document.write("</table>");
}


// final stuff
// the main program ---

jsi = new makelinks(linksize);
document.write("<title>站内查询</title>");
searchlinks(jsi, prompt("输入查询关键字:","输入查询关键字:"));
document.write("<hr>");
document.write("按<b>search again</b>再次查询<hr>");
document.write("<form><input type=button οnclick='history.go(0)' value='search again'></form>");

// show all the links
//document.write("<table border>");
//showall(jsi);
//document.write("</table>");

</script>
    以上就是本篇文章【站内搜索脚本例子二(JavaScript)】的全部内容了,欢迎阅览 ! 文章地址:https://sicmodule.kub2b.com/quote/12427.html 
     栏目首页      相关文章      动态      同类文章      热门文章      网站地图      返回首页 企库往资讯移动站https://sicmodule.kub2b.com/mobile/,查看更多   
发表评论
0评