您好!很高兴为您答疑。
如果想要在火狐下使用该方法,可以尝试重写一下。实例代码请参考:
<script language=”javascript”>
function isIE(){ //ie?
if (window.navigator.userAgent.toLowerCase().indexOf(“msie”)>=1)
return true;
else
return false;
}
if(!isIE()){ //firefox innerText define
HTMLElement.prototype.__defineGetter__( “innerText”,
function(){
var anyString = “”;
var childS = this.childNodes;
for(var i=0; i<childS.length; i++) {
if(childS[i].nodeType==1)
anyString += childS[i].tagName==”BR” ? ‘\n' : childS[i].textContent;
else if(childS[i].nodeType==3)
anyString += childS[i].nodeValue;
}
return anyString;
}
);
HTMLElement.prototype.__defineSetter__( “innerText”,
function(sText){
this.textContent=sText;
}
);
}
</script>
如果对我们的回答存在任何疑问,欢迎继续问询。
追问没必要这么复杂,target.innerText || target.innerHTML;,这句话已经可以了,已经知道了,不用回答了