<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=GBK"/>
<title>HelloWorld</title>
<linkhref="style.css"rel="externalnofollow"rel="stylesheet"type="text/css">
<scripttype="text/javascript">
sources=newArray("www.sina.com","www.baidu.com","www.google.com","www.sina.org","www.baidu.ogr.cn");
tabinfo="";
flag=newArray(sources.length);
for(vari=0;i<flag.length;i++)
flag[i]=false;
functionimmediately(){
varelement=document.getElementById("i1");
if("\v"=="v"){
element.onpropertychange=webChange;
}else{
element.addEventListener("input",webChange,false);
}
functionwebChange(){
vartab=document.all("dl1");
for(vari=0;i<flag.length;i++)
flag[i]=false;//重新初始化
if(element.value){
varcontent=document.getElementById("i1").value;
for(vari=0;i<sources.length;i++){
if(sources[i].indexOf(content)!=-1){
flag[i]=true;
}
}
for(varj=0;j<flag.length;j++){
if(flag[j]){//sources[j]有与文本框文字相同的内容
if(tab.rows.length>0){
for(vark=0;k<tab.rows.length;k++)
if(tab.rows[k].cells[0].innerText.indexOf(content)==-1)
tab.deleteRow(k);
}
for(vark=0;k<tab.rows.length;k++){
tabinfo+=tab.rows[k].cells[0].innerText;
}
if(tabinfo.indexOf(sources[j])==-1){
nrow=tab.insertRow(0);
newcell=nrow.insertCell();
newcell.innerHTML=sources[j]
}
tabinfo="";
}
}
}
}
}
</script>
<scriptlanguage="javascript">
varlastObj=null;
functionbackBlack(){
event.srcElement.style.background="gray";
forceBackC6();
if(event.srcElement.tagName=="TD"){
lastObj=event.srcElement;
}
fillData();
}
functionbackC6(){
event.srcElement.style.background="#CCCCCC";
}
functionforceBackC6(){
if(lastObj!=null)
lastObj.style.background="#F8F8FF";
}
functionfillData(){
if(lastObj.innerHTML!=null)
document.all.i1.value=lastObj.innerHTML;
}
functioninit(){
Layer1.style.top=i1.offsetTop+40;
Layer1.style.left=i1.offsetLeft;
Layer1.style.visibility="visible";
}
functionhideBelow(){
Layer1.style.visibility="hidden";
}
</script>
</head>
<body>
<inputtype="text"id="i1"style="height:20px"onFocus="init()"onBlur="hideBelow()"/>
<scripttype="text/javascript">
immediately();
</script>
<divid="Layer1">
<tableid="dl1"class="midHead"cellspacing="0"onMouseOut="backC6()"onMouseOver="backBlack()"border="0">
</table>
</div>
<br>
</body>
</html>