推广 热搜: page  数据  小红  红书  考试  论文  数据分析  关键词  哪些  搜索 

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

   日期:2024-12-25     移动:https://sicmodule.kub2b.com/mobile/quote/12427.html
<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>
本文地址:https://sicmodule.kub2b.com/quote/12427.html     企库往 https://sicmodule.kub2b.com/ , 查看更多

特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


0相关评论
相关最新动态
推荐最新动态
点击排行
网站首页  |  关于我们  |  联系方式  |  使用协议  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2020018471号