Rumah  >  Artikel  >  hujung hadapan web  >  站内搜索脚本例子六(javascript)_Javascript教程

站内搜索脚本例子六(javascript)_Javascript教程

黄舟
黄舟asal
2016-12-21 15:38:571041semak imbas

脚本说明:
第一步:把如下代码加入区域中

<script><br><!-- 如下是表单合法性检查,主要是避免一些非法字符的查询! --><br>function validate_form()<br>{<br>txt = document.form.search.value;<br>newindex = document.form.numhits.selectedIndex;<br>dahits = document.form.numhits[newindex].value;<br>newindexb = document.form.whichdir.selectedIndex;<br>dadir = document.form.whichdir[newindexb].value;<br>if (txt.indexOf(".") != -1){<br>alert("Search is invalid! Contains a '.'"); return;}<br>if (txt.indexOf(",") != -1){<br>alert("Search is invalid! Contains a ','"); return;}<br>if (txt.indexOf("@") != -1){<br>alert("Search is invalid! Contains a '@''"); return;}<br>if (txt.indexOf("!") != -1){<br>alert("Search is invalid! Contains a '!''"); return;}<br>if (txt.indexOf("#") != -1){<br>alert("Search is invalid! Contains a '#''"); return;}<br>if (txt.indexOf("$") != -1){<br>alert("Search is invalid! Contains a '$''"); return;}<br>if (txt.indexOf("%") != -1){<br>alert("Search is invalid! Contains a '%''"); return;}<br>if (txt.indexOf("^") != -1){<br>alert("Search is invalid! Contains a '^''"); return;}<br>if (txt.indexOf("&") != -1){<br>alert("Search is invalid! Contains a '&''"); return;}<br>if (txt.indexOf("*") != -1){<br>alert("Search is invalid! Contains a '*''"); return;}<br>if (txt.indexOf("(") != -1){<br>alert("Search is invalid! Contains a '(''"); return;}<br>if (txt.indexOf(")") != -1){<br>alert("Search is invalid! Contains a ')''"); return;}<br>if (txt.indexOf("[") != -1){<br>alert("Search is invalid! Contains a '[''"); return;}<br>if (txt.indexOf("]") != -1){<br>alert("Search is invalid! Contains a ']''"); return;}<br>if (txt.indexOf(";") != -1){<br>alert("Search is invalid! Contains a ';''"); return;}<br>if (txt.indexOf(":") != -1){<br>alert("Search is invalid! Contains a ':''"); return;}<br>if (txt.indexOf("<") != -1){<br/>alert("Search is invalid! Contains a &#39;<&#39;&#39;"); return;}<br/>if (txt.indexOf(">") != -1){<br>alert("Search is invalid! Contains a '>''"); return;}<br>if (txt.indexOf("?") != -1){<br>alert("Search is invalid! Contains a '?''"); return;}<br>if (txt.indexOf("=") != -1){<br>alert("Search is invalid! Contains a '=''"); return;}<br>if (txt.indexOf("+") != -1){<br>alert("Search is invalid! Contains a '+''"); return;}<br>else<br>{<br>jsi = new makeLinks(linksize);<br>searchLinks(jsi, txt, dahits, dadir);<br>document.write('</OL>');<br>document.write('<font color=red>....... 查询结果结束 .......</font><P>');<br>document.write('<hr>');<br>document.write('</body></html>');<br>}</p> <p>}<br></script>


 
 


 


关键字(小写字符,支持中文):  

 





返回记录数:  

检索分类  

 







 




 
 

 以上就是站内搜索脚本例子六(javascript)_Javascript教程的内容,更多相关内容请关注PHP中文网(www.php.cn)! 


Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn