һ
 ע

QQ¼

ֻһٿʼ

ƼĶ

+
̳ WEBҳǰ뿪 򿪷ݿ⡬

asp+ajaxgoogleʾЧ

[]
421515 websjy 2012-2-24 14:17:34
| ʾȫ¥
1F

ϵ½עᣬύѣø๦ܣϴزIJޣ

Ҫ ¼ ſػ鿴ûʺţע  

x
ǰʱgoogle suggest˺ܶ඼,ԼЩʱдһ,google suggest һ,ԼٽDZΧŶ
:
javascript.js
  1. var url="ajax.asp"; //ַ̨
  2. var time_delayajax=300; //ӳ
  3. var time_delayupdown=100; //ӳ
  4. obj_div.style.top = (xtop + 20) + "px"; //20ĸ߶,ʵ
  5. ajax_xmlhttp.send("sift_value="+escape(temp_value)); //ύֵ̨
  6. dd=d+"<li onmouseover=\"overli("+i+");\" onmousedown=\"downli("+i+")\" onmouseup=\"upli("+i+",event)\" onmousemove=\"moveli();\"><span>Լ"+c[1]+"</span>"+c[0]+"</li>";//****liʾ
  7. ̨ʽΪ'ı1,ı2'.....
  8. 'java,2''javascript,11''javaʾ,22'
  9. default.css
  10. ƴ :
  11. .ajaxsearch {
  12. width:300px; //ʾĿ
  13. }
ƴ
ҳindex.html

:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <link rel="stylesheet" type="text/css" href="default.css" />
  6. <script language="JavaScript" src="javascript.js" type="text/javascript"></script>
  7. <title>Google suggest߷ʾ</title>
  8. </head>
  9. <body onResize="removediv();">
  10. <div style="margin:20px 50px">
  11. <input style="width:298px;height:18px" type="text" autocomplete="off" onBlur="blurdeal();" onKeyDown="keydowndeal(event);" onFocus="focusdeal(event);" />
  12. </div>
  13. </body>
  14. </html>
ƴ

Ѿͬ websjy΢
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ
͵ 2013-8-21 13:35:03
| ʾȫ¥
Ƽ

Ƕ̬⡣
ʱdbм¼
DBûƥ¼Ļᱣ浽dbȥ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
pkyxm 2017-11-21 23:53:48
Ƽ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
() ֧
ְ01 2017-10-13 13:59:41
| ʾȫ¥
Ƽ

uu,uuµַע,վ



iujlb.com
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
 ¥| websjy 2012-2-24 14:19:35
| ʾȫ¥
5F
űjavascript.js
:
  1. ///////////////////////////////ʾ/////////////////////////////////
  2. var obj_div; //ʾ
  3. var obj_input; //
  4. var main_delay; //жֵ仯ӳٶ
  5. var ajax_delay; //ajaxӳ
  6. var updown_delay; //ӳٶ
  7. var ajax_xmlhttp; //ajax
  8. var div_word=null; //ǰʾӦֵ
  9. var li_num=-1; //αλ,ʾ㱻ѡеli,0ʼ
  10. var li_down=-1; //갴ʾ
  11. var value_ed=""; //ӳǰֵ
  12. var value_ing=""; //ǰֵ
  13. var value_unexit=""; //ûнֵͷ
  14. var updown_run=false; //
  15. var ajax_run=false; //trueΪ,falseֹͣajax
  16. var ajax_run_ing=false; //true,false
  17. var input_focus=false; //ı򽹵
  18. var url="ajax.asp"; //ַ̨
  19. var time_delayajax=300; //ӳ
  20. var time_delayupdown=100; //ӳ
  21. var $=function(Fun_id){
  22. return document.getElementById(Fun_id);
  23. }
  24. try{
  25. ajax_xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
  26. }catch(e){
  27. try{
  28. ajax_xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
  29. }catch(e){
  30. try{
  31. ajax_xmlhttp= new XMLHttpRequest();
  32. }catch(e){ajax_xmlhttp=null;}
  33. }
  34. }
  35. ////////////////////////ʾ////////////////////////
  36. function createajaxdiv(){
  37. var create_div = document.createElement("div");
  38. create_div.type = "div";
  39. var promptdiv = document.body.appendChild(create_div);
  40. promptdiv.className = "ajaxsearch";
  41. obj_div=promptdiv;
  42. }
  43. ////////////////////////ʾλ////////////////////////
  44. function removediv(){
  45. if(!obj_div || !obj_input)return false;
  46. if(obj_div.style.display=="none")return false;
  47. var obj=obj_input;
  48. var xtop=0;
  49. var xleft=0;
  50. while(obj){
  51. xtop += obj["offsetTop"];
  52. xleft += obj["offsetLeft"];
  53. obj = obj.offsetParent;
  54. }
  55. obj_div.style.left = xleft + "px";
  56. obj_div.style.top = (xtop + 20) + "px"; //20ĸ߶,ʵ
  57. li_down=-1;
  58. }
  59. ////////////////////////ʾ////////////////////////
  60. function hideajaxdiv(){
  61. obj_div.style.display="none";
  62. li_down=-1;
  63. }
  64. ////////////////////////ñѡ<li>cssʽ////////////////////////
  65. function setlistyle(){
  66. for(var i=0;i<obj_div.firstChild.childNodes.length;i++){
  67. obj_div.firstChild.childNodes[i].id="";
  68. }
  69. if(li_num!=-1)obj_div.firstChild.childNodes[li_num].id="liseleted";
  70. }
  71. ////////////////////////꾭ʾ////////////////////////
  72. function overli(Fun_seletedlinum){
  73. if(li_num==-1)value_ing=obj_input.value;
  74. li_num=Fun_seletedlinum;
  75. setlistyle();
  76. }
  77. ////////////////////////϶ʾ////////////////////////
  78. function moveli(){
  79. if(window.getSelection){
  80. setfocus();
  81. window.getSelection().removeAllRanges();
  82. }else{
  83. document.selection.empty();
  84. setfocus();
  85. }
  86. }
  87. ////////////////////////갴ʾ////////////////////////
  88. function downli(Fun_seletedlinum){
  89. if(!obj_input)return false;
  90. li_down=Fun_seletedlinum;
  91. input_focus=true;
  92. }
  93. ////////////////////////굯ʾ////////////////////////
  94. function upli(Fun_seletedlinum,Fun_event){
  95. if(!obj_input)return false;
  96. if(Fun_event.button==2){li_down=-1;return}
  97. if(li_down!=Fun_seletedlinum){
  98. li_down=-1;
  99. return false;
  100. }
  101. clearTimeout(ajax_delay);
  102. clearTimeout(updown_delay);
  103. updown_run=true;
  104. ajax_run=false;
  105. ajax_run_ing=false;
  106. li_num=-1;
  107. div_word=null;
  108. value_ed=obj_div.firstChild.childNodes[Fun_seletedlinum].childNodes[1].nodeValue;
  109. obj_input.value=value_ed;
  110. value_ing=value_ed;
  111. hideajaxdiv();
  112. obj_div.innerHTML="";
  113. }
  114. ////////////////////////ıȡ///////////////////////
  115. function setfocus(){
  116. if(window.event){
  117. var r = obj_input.createTextRange();
  118. r.moveStart('character',obj_input.value.length);
  119. r.collapse(true);
  120. r.select();
  121. }else{
  122. obj_input.selectionStart=obj_input.value.length;
  123. obj_input.focus();
  124. }
  125. }
  126. ////////////////////////ıʧȥ////////////////////////
  127. function blurdeal(){
  128. if(input_focus==true){
  129. setfocus();
  130. setTimeout("setfocus()");
  131. return false;
  132. }
  133. updown_run=false;
  134. ajax_run=false;
  135. ajax_run_ing=false;
  136. clearInterval(main_delay);
  137. clearTimeout(ajax_delay);
  138. clearTimeout(updown_delay);
  139. hideajaxdiv();
  140. if(value_ed!=obj_input.value)obj_div.innerHTML="";
  141. }
  142. ////////////////////////ıȡ////////////////////////
  143. function focusdeal(Fun_event){
  144. if(!obj_div)createajaxdiv();
  145. if(input_focus==true){
  146. input_focus=false;
  147. return false;
  148. }
  149. var obj=((window.event)?Fun_event.srcElement:Fun_event.target);
  150. if(obj.type!="text")return false;
  151. updown_run=true;
  152. ajax_run=true;
  153. ajax_run_ing=false;
  154. if(obj_input==obj && value_ed==obj.value && obj_div.innerHTML!=""){
  155. obj_div.style.display="block";
  156. removediv();
  157. }else{
  158. obj_input=obj;
  159. value_ed=obj.value;
  160. value_ing=obj.value;
  161. value_unexit="";
  162. li_num=-1;
  163. li_down=-1;
  164. div_word=null;
  165. obj_div.innerHTML="";
  166. removediv();
  167. }
  168. main_delay=setInterval("mainajax()",10);
  169. }
  170. ////////////////////////////////////////////////
  171. function mainajax(){
  172. if(value_ed==obj_input.value)return false;
  173. if(value_unexit!="" && (obj_input.value).indexOf(value_unexit)==0){hideajaxdiv();obj_div.innerHTML="";return false;}
  174. if(value_ed!=obj_input.value && ajax_run_ing==false){
  175. ajax_run=true;
  176. value_ed=obj_input.value;
  177. clearTimeout(ajax_delay);
  178. if(obj_input.value!=""){
  179. ajax_delay=setTimeout("getsearch();",time_delayajax);
  180. }else{
  181. hideajaxdiv();
  182. obj_div.innerHTML="";
  183. ajax_run=false;
  184. return false;
  185. }
  186. }
  187. }
  188. ////////////////////////ȡ////////////////////////
  189. function getsearch(){
  190. var temp_value=obj_input.value;
  191. if(ajax_xmlhttp==null){
  192. return false;
  193. }else if(ajax_xmlhttp.readyState!=0){
  194. ajax_xmlhttp.abort();
  195. ajax_run_ing=false;
  196. }
  197. ajax_xmlhttp.onreadystatechange=function(){
  198. if(ajax_run==false){ajax_xmlhttp.abort();ajax_run_ing=false;return false;}
  199. if(ajax_xmlhttp.readyState==4){
  200. obj_div.innerHTML="";
  201. if(ajax_xmlhttp.status==200 || ajax_xmlhttp.status==304){
  202. var contant=ajax_xmlhttp.responseText;
  203. if(contant!="" && ajax_run==true){
  204. div_word=temp_value;
  205. obj_div.innerHTML=resetcontant(contant);
  206. obj_div.style.display="block";
  207. removediv();removediv();
  208. }else{
  209. hideajaxdiv();
  210. }
  211. updown_run=true;
  212. ajax_run_ing=false;
  213. li_num=-1;
  214. if(contant=="")value_unexit=temp_value;
  215. }
  216. }
  217. }
  218. ajax_xmlhttp.open("post",url,true);
  219. ajax_xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  220. ajax_run_ing=true;
  221. ajax_xmlhttp.send("sift_value="+escape(temp_value)); //ύֵ̨
  222. }
  223. ///////////////////////////////////////////////
  224. function resetcontant(Fun_contant){
  225. if(Fun_contant==null || Fun_contant=="")return "";
  226. var a=Fun_contant.substring(1,Fun_contant.length-1);
  227. if(Fun_contant==null || Fun_contant=="")return "";
  228. var b=a.split("''");
  229. var c;
  230. var d;
  231. d="<ul>";
  232. for(var i in b){
  233. c=b[i].split(",");

  234. d=d+"<li onmouseover=\"overli("+i+");\" onmousedown=\"downli("+i+")\" onmouseup=\"upli("+i+",event)\" onmousemove=\"moveli();\"><span>Լ"+c[1]+"</span>"+c[0]+"</li>";

  235. }
  236. d=d+"<li onmousedown=\"input_focus=true;li_down=-1;\" onmouseup=\"li_down=-1\" onmousemove=\"moveli();\"><span><a class=\"shutajaxdiv\" onclick=\"hideajaxdiv();\">ر</a></span></li>"
  237. d=d+"</ul>";
  238. return d;
  239. }
  240. ////////////////////////¼////////////////////////
  241. function keydowndeal(Fun_event){
  242. var keyc=((window.event)?Fun_event.keyCode:Fun_event.which);
  243. if(keyc==13){hideajaxdiv();return false;}
  244. if(keyc==27){
  245. if(obj_div.style.display=="block" && li_num>-1)value_ed=obj_input.value=value_ing;
  246. hideajaxdiv();
  247. return false;
  248. }
  249. if(keyc==40 || keyc==38){
  250. if(div_word==obj_input.value && obj_div.style.display=="none" && obj_div.innerHTML!=""){
  251. obj_div.style.display="block";
  252. removediv();
  253. return false;
  254. }
  255. if(li_num==-1){
  256. if(div_word!=obj_input.value)return false;
  257. }else{
  258. if(div_word!=value_ing)return false;
  259. }
  260. if(updown_run==false || ajax_run_ing==true || obj_div.style.display=="none")return false;
  261. updown_delay=setTimeout("updownli("+keyc+")",time_delayupdown);
  262. updown_run=false;
  263. }
  264. }
  265. ////////////////////////ƶli////////////////////////
  266. function updownli(Fun_key){
  267. if(!obj_div){return false;}
  268. updown_run=true;
  269. if(li_num==-1){
  270. if(div_word!=obj_input.value){hideajaxdiv();obj_div.innerHTML="";li_num=-1;return false;}
  271. }else{
  272. if(div_word!=value_ing){hideajaxdiv();obj_div.innerHTML="";li_num=-1;return false;}
  273. }
  274. if(updown_run==false)return false;
  275. if(li_num==-1)value_ing=value_ed;
  276. if(Fun_key==40){
  277. if(li_num<obj_div.firstChild.childNodes.length-2){
  278. li_num++;
  279. }else{
  280. li_num=-1;
  281. }
  282. }
  283. if(Fun_key==38){
  284. if(li_num>=0){
  285. li_num--;
  286. }else{
  287. li_num=obj_div.firstChild.childNodes.length-2;
  288. }
  289. }
  290. if(li_num!=-1){
  291. value_ed=obj_input.value=obj_div.firstChild.childNodes[li_num].childNodes[1].nodeValue;
  292. }else{
  293. value_ed=obj_input.value=value_ing;
  294. }
  295. setlistyle();
  296. }
ƴ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
 ¥| websjy 2012-2-24 14:20:32
| ʾȫ¥
6F
̨ajax.asp
:
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
  2. <%option explicit%>
  3. <%Response.CodePage="65001"%>
  4. <%Response.Charset="utf-8" %>
  5. <!--#include file="conn.asp"-->
  6. <%
  7. dim Sift_value
  8. dim Sql,Rs,I,Num
  9. dim Contant
  10. Contant=""
  11. Num=10
  12. Sift_value=replace(unescape(request.form("sift_value")),"""","""""")
  13. Sql="select top "&Num&" keyword,matchnum from search where keyword like """&Sift_value&"%"" order by id"
  14. set Rs=server.CreateObject("adodb.recordset")
  15. Rs.open Sql,Conn,1,1
  16. if not (Rs.eof and Rs.bof) then
  17. for I=0 to Num-1
  18. Contant=Contant&"'"&rs(0)&","&rs(1)&"'"
  19. Rs.movenext
  20. if Rs.eof then exit for
  21. next
  22. end if
  23. response.Write(Contant)
  24. Rs.close
  25. set Rs=nothing
  26. %>
ƴ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
͵ 2012-11-5 12:48:17
| ʾȫ¥
7F
֣е㷱ˣ㿴www.epermarket.comԱעҸ֪ģģһiframe͸㶨ˡ

̬ܲܶݿ⣿  ظ 2012-11-6 09:36
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
happy175 2012-11-6 09:36:52
| ʾȫ¥
8F
͵ 2012-11-5 12:48
֣е㷱ˣ㿴www.epermarket.comԱעҸ֪ģģһiframe͸㶨ˡ ...

̬ܲܶݿ⣿
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
2014-3-20 06:18:52
| ʾȫ¥
9F
˵úãҹ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
2014-3-27 04:03:35
| ʾȫ¥
10F
ӵĶһ¿
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
khrqv 2014-10-10 23:32:45
| ʾȫ¥
11F
ܲİ
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
kaorou37 2015-11-30 21:11:02
| ʾȫ¥
12F
Ҫ,¥ͷDz
Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ ֧
12һҳ
б

ֹ

²

̳¡ͼƬѷϴվԭתԻ,µİȨԭ
վַİȨ֪ͨǵĹԱ,Ա(Email:admin@websjy.com)ʱȡȨɾ
ܾκκʽڱ̳л񹲺͹ִ!

QQ| 42011102000510|Archiver|ֻ|Դ ( ICP14013341-1

GMT+8, 2017-12-17 19:48

Powered by Discuz! X3.2

ԴԴվ  ԴAPPӦ֮

ٻظ ض б