站內(nèi)搜索腳本例子5(JavaScript)
發(fā)表時(shí)間:2024-01-07 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]腳本說(shuō)明: 第一步:把如下代碼加入<body>區(qū)域中 <SCRIPT LANGUAGE="JavaScript"> <!-- Hide Script from Old Browsers Keyword = new Object(); Descrip...
腳本說(shuō)明:
第一步:把如下代碼加入<body>區(qū)域中
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide Script from Old Browsers
Keyword = new Object();
Descrip = new Object();
Address = new Object();
// Keyword[0] = n (where n is the number of keywords which can be searched
Keyword[0] = 5 //對(duì)應(yīng)查詢組的數(shù)量;
Keyword[1] = "javascript"
Descrip[1] = "最全的javascript資源站-javascript2000.com"
Address[1] = "http://www.javascript2000.com"
Keyword[2] = "javascript"
Descrip[2] = "很好的javascript站點(diǎn)"
Address[2] = "http://www.cnlot.com/"
Keyword[3] = "javascript"
Descrip[3] = "java神捕"
Address[3] = "http://pcafei.3322.net/"
Keyword[4] = "javascript"
Descrip[4] = "精彩天地"
Address[4] = "http://demoy.3322.net/"
Keyword[5] = "javascript"
Descrip[5] = "國(guó)外最大的javascript資源站"
Address[5] = "http://www.javascript.com/"
function checkDatabase() {
var Found = false
var Item = document.forms[0].searchfor.value.toLowerCase();
stats='toolbar=no,location=no,directories=no,status=no,menubar=no,'
stats += 'scrollbars=yes,resizable=yes'
MsgBox = window.open ("","msgWindow",stats)
MsgBox.document.write("<head><title>查詢結(jié)果</title></head>");
MsgBox.document.write ("<BODY BGCOLOR=#ffffff TEXT=#000000 LINK=#000080 VLINK=#800040
ALINK=#FF0000><CENTER>查詢結(jié)果</CENTER>")
MsgBox.document.write ("For the keyword: "+Item+"<HR>");
for (var i=1; i <= Keyword[0]; i++) {
if(Item == Keyword[i]) {
Found = true;
MsgBox.document.write (Descrip[i]+"<BR><A HREF="+Address[i]+">Click Here To View</A><br>")
}
}
if(!Found)
MsgBox.document.write ("沒(méi)有發(fā)現(xiàn)與該關(guān)鍵詞有關(guān)的條目。")
MsgBox.document.write ("<H6>Enjoy it!<BR><A HREF=http://java2000.126.com>http://java2000.126.com</A></H6>")
MsgBox.document.write ("<FORM class='pt9'><CENTER>")
MsgBox.document.write ("<INPUT type='button' value='關(guān)閉查詢窗口' onClick = 'self.close()'>")
MsgBox.document.write ("</CENTER></FORM>") }
// -->
</SCRIPT>
如下代碼生成查詢表單界面:
<form name="form1">
<u>請(qǐng)輸入查詢關(guān)鍵詞:</u><br>
<input type="text" name="searchfor" value="" size=20>
<input type="button" value="查詢" onClick="checkDatabase()" name="button">
<br>
<!-- End Of File -->
<font color="#FF0000">輸入小寫(xiě)字符</font>
<p>
</form>