最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
google 搜索提示
时间:2022-07-02 23:15:58 编辑:袖梨 来源:一聚教程网
google 搜索提示,google 自动提示 仿google的下拉提示 <%
Response.ContentType="text/xml"
search=Trim(request("search"))
sql="select top 10 [ytitle] from table1 where [ytitle] like '"&search&"%' order by [ytime]"
rs.open sql,conn,1,1
str=""&vbnewline
str=str&"
If rs.eof Then
Else
i=1
Do While Not rs.eof
str=str&"
str=str&"
str=str&"
i=i+1
rs.movenext
loop
End If
str=str&"
rs.close
response.write str
%>这种做法是把要搜索的内容以xml 保存然后再用xmldom 读取,缺点是太浪费资源.
xmldom文件代码如下:
var searchReq=createAjaxObj();
function createAjaxObj()
{
var httprequest=false;
if(window.XMLHttpRequest)
{
httprequest=new XMLHttpRequest();
if(httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml');
}
else if (window.ActiveXObject)
{
//IE
try
{
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
}
}
}
return httprequest
}
function searchSuggest()
{
if (document.getElementById('txtSearch').value.length>0)
{
var str=escape(document.getElementById('txtSearch').value);
url="search.asp?search="+str+ "&t=" + new Date().getTime();
searchReq.open("get",url);
searchReq.onreadystatechange=handleSearchSuggest;
searchReq.send(null);
}
else
{
document.getElementById("search_suggest").innerHTML="";
document.getElementById("search_suggest").style.display="none";
}
}
function handleSearchSuggest()
{
if(searchReq.readyState==4)
{
var ss=document.getElementById("search_suggest");
ss.innerHTML="";
s0=searchReq.responseText.length;
if (s0>0)
{
xmldoc=searchReq.responseXML;
var message_nodes=xmldoc.getElementsByTagName("message");
var n_messages=message_nodes.length;
if (n_messages<=0)
{
document.getElementById("search_suggest").innerHTML="";
document.getElementById("search_suggest").style.display="none";
}
else
{
document.getElementById("search_suggest").style.display="block";
for (i=0;i
var suggest='
suggest+='onclick="javascript:setSearch(this.innerHTML);"';
suggest +='class="suggest_link">'+message_nodes[i].getElementsByTagName("text")[0].firstChild.data+'
ss.innerHTML +=suggest;
}
}
}
else
{
document.getElementById("search_suggest").innerHTML="";
document.getElementById("search_suggest").style.display="none";
}
}
else
{
//alert('网络连接失败');
}
}
function suggestOver(div_value)
{
div_value.className='suggest_link_over';
}
function sugggestOut(div_value)
{
div_value.className='suggest_link';
}
function setSearch(div_value)
{
document.getElementById("txtSearch").value=div_value;
document.getElementById("search_suggest").innerHTML="";
document.getElementById("search_suggest").style.display="none";
}
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22