要完成此效果把如下代碼加入到區(qū)域中
<script language="javascript">
var key = "";
function makeEntry (){
this.Date = "";
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] = "網(wǎng)易"
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] = "新浪網(wǎng)"
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("
");
document.write("" + links[index].Date +" | ");
document.write("" + links[index].Name + " | ");
document.write("" + links[index].Desc + " |
");
//document.write("
");
}
function searchLinks(links, keyword){
document.write("搜尋結(jié)果: " +keyword +"
");
document.write("
");
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+ "
" +links[q].Name +"")
//document.write("搜尋結(jié)果: "+keyword+ "
" );
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("
");
}
// final stuff
// the main program ---
jsi = new makeLinks(linksize);
document.write("
站內(nèi)查詢");
searchLinks(jsi, prompt("輸入查詢關(guān)鍵字:","輸入查詢關(guān)鍵字:"));
document.write("
");
document.write("按
search again再次查詢
");
document.write("
");
// show all the links
//document.write("
");
//showAll(jsi);
//document.write("
");
</script>