html 复制代码 代码如下: 输入框自动匹配字符~ 但是遇到一个问题~所有匹配的字符要事先写好~大概如果是大型网站的话~应该是利用数据库的记录吧 看代码 html 复制代码 代码如下: <BR>ul,li{margin: 0; padding: 0;width:100%;} <BR> <BR>function checkword() <BR>{ <BR> var wordvalue=document.getElementById("word").value.toLowerCase(); <BR> var alltxt="all|big|cut|car\|daph8|eeg|egg|eat|fuck|fuck you|fix|good|hand|hidden|ill|jack|jad|kevin|long|man|number|oio|part|pp|quit|QQ|rest|reg|set|submit|time|tag|uuzo|view|windows|want|xy|xun|young|yuyu|z|David|David|哈哈|";//这里就是你所想要匹配的字符,可惜只能用于小型的论坛 <BR> var alltxtalltxtpp=alltxt.toLowerCase(); <BR> var alltxtalltxt_xiang=alltxt.split("|"); <BR> var alltxt_xiang1=alltxtpp.split("|"); <BR> var inhtml="<ul>" <BR> var isyou=0; <BR> for (i=0;i<alltxt_xiang1.length;i++) <BR> { <BR> if (alltxt_xiang1[i].substr(0,wordvalue.length)==wordvalue) <BR> { <BR> inhtmlinhtml=inhtml+"<li onclick=\"document.getElementById('word').value=this.innerHTML;document.getElementById('showmenu').style.display='none';\" onmouseover=\"this.style.backgroundColor='#666666'\" onmouseout=\"this.style.backgroundColor=''\">"+alltxt_xiang[i]+""; <BR> isyou=1; <BR> } <BR> } <BR> inhtmlinhtml=inhtml+""; <BR> if (isyou==1) <BR> { <BR> document.getElementById("showmenu").innerHTML=inhtml; <BR> document.getElementById("showmenu").style.display=""; <BR> } <BR> else <BR> { <BR> document.getElementById("showmenu").innerHTML=""; <BR> document.getElementById("showmenu").style.display="none"; <BR> } <BR> if (wordvalue=="") <BR> { <BR> document.getElementById("showmenu").innerHTML=""; <BR> document.getElementById("showmenu").style.display="none"; <BR> } <BR>} <BR>