1:找到uploads/templets/default/head.htm
2: 找到
<input name="q" type="text" class="search-keyword" id="aa" value="在这里搜索..." onfocus="if(this.value=='在这里搜索...'){this.value='';}"
onkeydown="document.getElementById('ssxlk').style.display= 'block';"
oninput="_getvalue()"
onblur="if(this.value==''){this.value='在这里搜索...';}" />
添加 autocomplete="off" 系统input 默认autocomplete 为on
3:在相应位置添加一个div id="ssxlk";
4:添加javascript代码:
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" >
function _getvalue()
{
var res = "id="+document.getElementById('aa').value;
//var gvalue = document.getElementByID().value;
getajax('ssxxl.php',res,b);
}
function b(a)
{
if(document.getElementById('aa').value=='')
{
document.getElementById('ssxlk').innerHTML='';
}
else
{
document.getElementById('ssxlk').innerHTML=a;
}
//alert(a);
}
</script>
5:ajax.js页面:
function getajax(url,j,responsefunction){
if(url){
var xhr=ajax();
xhr.open("POST",url,true);
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status==200){
responsefunction(unescape(xhr.responseText));
}else{
alert("页面读取失败");
}
}
};
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xhr.send(j); //发送请求
}else{
alert("未知错误,请查识");
}
}
function ajax(){
var http_request;
if(window.XMLHttpRequest){
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){
http_request.overrideMimeType("text/xml");
}
}else if(window.ActiveXObject){
try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
try{
http_request=new ActiveXobject("Microsoft.XMLHttp");
}catch(e){
}
}
}
if(!http_request){
window.alert("创建XMLHttp对象失败!");
return false;
}
return http_request;
}
6:ssxxl.php页面
<?php
mysql_connect('localhost','root','root');
mysql_select_db('dedecms');
mysql_query('set names utf8');
$sql = "select `typename` from `dede_arctype` where `typename` like '%".$_POST['id']."%' limit 0,9;";
//print_r($sql);
$result = mysql_query($sql);
if($row = mysql_fetch_array($result))
{
do
{
echo $row[0];
echo "<br />";
}
while($row = mysql_fetch_array($result));
}
//echo 'aaaaaa';
?>
页面效果为: