|
作者: q70213526 [q70213526] 版主 | 登录 |
做一个网页。页内有很多的方字,每一组方字是一个超链接。 怎么做一个站内搜索,并能直接定位到搜索目标,方便访问者浏览??? 谢谢 |
地主 发表时间: 04-01-18 16:42 |
回复: ltb [ltb] 论坛用户 | 登录 |
<HTML> <HEAD> <title>精彩春风之自己QQ</title> <link rel="stylesheet" type="text/css" href="forum.css"> </HEAD> <BODY onload=online() scroll=no topmargin="0" leftmargin="0" style="background-color: #8482C6; color: #FFFFFF; border: 2 solid #FFFFFF; padding: 0"> <marquee><font color=black>海内存知己,天涯若比邻</font></marquee> <script language="vbscript"> Function bytes2BSTR(vIn) strReturn="" For i=1 To LenB(vIn) ThisCharCode=AscB(MidB(vIn,i,1)) If ThisCharCode<&H80 Then strReturn=strReturn&Chr(ThisCharCode) Else NextCharCode=AscB(MidB(vIn,i+1,1)) strReturn=strReturn&Chr(CLng(ThisCharCode)*&H100+CInt(NextCharCode)) i=i+1 End If Next bytes2BSTR=strReturn End Function </script> ' 以上转换代码用于解决无法显示汉字 <script language="javascript"> var lengt=0; ' 消除右键功能 function no(){ alert("噢,不支持右键!"); self.event.returnValue=false; } ' 弹出QQ对话框 function sqq(uid,id){ window.open("sqq.asp?id="+id+"&uid="+uid,"_blank","width=400,height=180"); } ' 此函数用于显示在线人员 function online(){ var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("post","online.asp",false); xmlhttp.send(); var xmldom=new ActiveXObject("Microsoft.XMLDOM"); xmldom.async=false; body=bytes2BSTR(xmlhttp.responseBody); xmldom.loadXML(body); if(xmldom.parseError.errorCode!=0){ window.open("refresh2.asp","_self"); ' 防止有些用户不支持xml return } else{ var uid=xmldom.documentElement.selectNodes("uid"); var id=xmldom.documentElement.selectNodes("id"); var sex=xmldom.documentElement.selectNodes("sex"); var xx=""; lengt=uid.length; for(var i=0;i<lengt;i++){ var im=""; if(id(0).text!="k") im="<img src=../jy/face/1.gif width=12 height=12>"; xx=xx+im+"<font color=red onclick=sqq('"+uid(i).text+"','"+id(i).text+"') style='cursor:hand' title='"+sex(i).text+"'>"+uid(i).text+"</font><br>"; } disonline.innerHTML=xx; window.setTimeout("online()",3000); } } </script> resfresh4.asp ' 用于弹出自己的消息时的对话框 <iframe src="refresh4.asp" width=0 height=2 marginwidth=0 marginheight=0 frameborder=0> </iframe> <input type=button value="在线好友:" class=ddyinput2> <div id=disonline style="height:230;overflow: auto"></div><br> ' 用到scriptlet技术 <OBJECT data=i11.htm height=14 style="HEIGHT: 93px; WIDTH: 770px" type=text/x-scriptlet width=14 VIEWASTEXT></OBJECT> </BODY> </HTML> xmlhttp.asp ' 处理xmlhttp请求 <%on error resume next Response.ContentType="text/xml" if Request.ServerVariables("REQUEST_METHOD")="POST" then set req=Server.CreateObject("Microsoft.XMLDOM") req.async=false req.load(Request) set conn=server.CreateObject("adodb.connection") conn.Open "odbc","uid","password" sql="select uid,id,sex from uidinfo order by id desc" set rs=server.CreateObject("adodb.recordset") rs.Open sql,conn Response.Write "<?xml version=""1.0"" ?>" Response.Write "<mess>" if not rs.EOF then do while not rs.EOF Response.Write "<id>"&trim(rs("id"))&"</id><uid>"&trim(rs("uid"))&"</uid><sex>"&trim(rs ("sex"))&"</sex>" rs.MoveNext loop else Response.Write "<id>k</id><uid></uid><sex></sex>" end if Response.Write "</mess>" if rs.State=1 then rs.Close set rs=nothing conn.Close set conn=nothing set req=nothing end if %> searchfiles.asp <% SearchTerm = request.form("term") Novalid=" a b c d e f g h i j k l m n o p q r s t u v w x y z yes no and more" NovalidResponse ="你输入的内容过于简单,请返回重试!" if instr(SearchTerm,Novalid)=0 then Response. Write ("<CENTER><H2>搜索结果</H2></CENTER>") FolderName= "FolderName" ShowList() else Response.Write NovalidResponse End if SearchResponse="" %> <% Sub ShowList() FolderToCheck = server.mappath("\") &"/" & FolderName & "/" Dim fs, f, f1, fc, s Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(FolderToCheck) Set fc = f.Files For Each f1 in fc Wfile = f1.name if right(Wfile, 5)=".html" OR right(Wfile, 4)=".htm" then Wfile2 = FolderToCheck & Wfile Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.OpenTextFile(Wfile2) ct = a.ReadAll a.close ct2=lcase(ct) SearchTerm2 = lcase(SearchTerm) if instr(ct2,SearchTerm2)>0 then if instr(ct,"</title>")>0 then longitud=instr(ct,"</title>") longitud=longitud -1 ct=left(ct,longitud) longitud2=len(ct) longitud=instr(ct,"<title>") longitud=longitud2 -longitud -6 ct=right(ct,longitud) else if instr(ct,"</TITLE>")>0 then longitud=instr(ct,"</TITLE>") longitud=longitud -1 ct=left(ct,longitud) longitud2=len(ct) longitud=instr(ct,"<TITLE>") longitud=longitud2 -longitud -6 ct=right(ct,longitud) end if end if SearchResponse= SearchResponse +"<TR><TD>"+ ct + "</TD><TD ALIGN=CENTER VALIGN=MIDDLE>" + " <A HREF=" + "/" + FolderName + "/" + Wfile +"> More </A></TD></TR>" longitud=0 ct="" end if end if Next Response.Write ("<HTML><HEAD><TITLE>搜索结果</TITLE></HEAD><BODY BGCOLOR=FFFFFF><CENTER>") Response.Write ("<TABLE BORDER=0 WIDTH=550><TR><TD BGCOLOR=C0C0C0><FONT SIZE=5><B>搜索结果</B></FONT></TD></TR></TABLE>") Response.Write ("<TABLE BORDER=0 WIDTH=550>") if SearchResponse<>"" then Response.Write SearchResponse else Response.Write ("<TR><TD>对不起,没有找到你输入的条目或关键词!</TD></TR>") end if Response.Write ("</TABLE>") Response.Write ("<TABLE BORDER=0 WIDTH=550><TR><TD BGCOLOR=C0C0C0 ALIGN=RIGHT><FONT SIZE=1>现在调用专业搜索引擎<A HREF= http://www.yahoo.com.cn/ </A></FONT></TD></TR></TABLE>") ' 任选一个你喜欢的引擎 Response.Write ("</CENTER></BODY></HTML>") End Sub %> |
B1层 发表时间: 04-01-18 20:46 |
回复: Newmyth21 [newmyth21] 论坛用户 | 登录 |
我看不明白,能不能加点中文注解啊! |
B2层 发表时间: 04-01-19 00:22 |
回复: zybzc [zybzc] 论坛用户 | 登录 |
头上不要 都试COPY |
B3层 发表时间: 04-01-19 13:23 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号