当前位置: 代码迷 >> Java Web开发 >> JS 在火狐兼容性有关问题 求大神指导
  详细解决方案

JS 在火狐兼容性有关问题 求大神指导

热度:892   发布时间:2016-04-16 22:07:28.0
JS 在火狐兼容性问题 求大神指导
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript">
window.onload=function(){

var li = document.getElementsByTagName("li");

for(var i = 0 ; i < li.length ; i ++){
li[i].onmouseover = function(){
this.style.backgroundColor = "#F90";
}
li[i].onmouseout = function(){
this.style.backgroundColor = "";
}
li[i].onclick = function(){
var msg = this.innerText;
var input = document.getElementById("ipt");
var cot = input.value;
input.value = cot + msg ;
document.getElementById("_ul").style.display="none";
}
}

document.getElementById("ipt").onkeyup = function(){
document.getElementById("_ul").style.display="";

if(document.getElementById("ipt").value == ""){
document.getElementById("_ul").style.display="none";

}
 
}

}
</script>
<title>邮箱</title>
</head>

<body>
<div id="panel">
  <input id="ipt" type="text" />
  <!--onmouseover="over(this)" onmouseout="out(this)" onclick="click(this)"-->
  <ul id="_ul" style="display:none">
    <li>@qq.com</li>
    <li>@sohu.com</li>
    <li>@163.com</li>
    <li>@baidu.com</li>
  </ul>
</div>
</body>
</html>

------解决方案--------------------
哥们,这么晚还在上班,小心身体呀,火狐对 innerText好像不支持的,改成innerHTML就好啦
//var msg = this.innerText;
 var msg = this.innerHTML;
  相关解决方案