国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

firefox瀏覽器不支持innerText的解決方法

2024-05-06 15:50:07
字體:
供稿:網(wǎng)友
在測試時(shí)發(fā)現(xiàn)firefox不支持innerText,該怎么辦呢?其實(shí)很簡單,本文為大家提供了一個(gè)解決方法,感興趣的朋友可以參考下,希望對(duì)大家有所幫助

js代碼:

復(fù)制代碼 代碼如下:


<script>
window.onload = function(){
<PRE class=javascript>if(window.navigator.userAgent.toLowerCase().indexOf("msie")==0){ //firefox innerText
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;
}
);
};</PRE>var test = document.getElementById("test");<BR>
var innerText_s = test.innerText;<BR>
if( innerText_s == undefined ){<BR>
alert( test.textContent ); // firefox<BR>
}else{ <BR>
alert( test.innerText);<BR>
};<BR>
<BR>
<BR>
}<BR>
<BR>
<BR>
</script><BR>
<PRE></PRE>
<P><BR>
</P>
<P>html代碼</P>
<P><div><BR>
      <span>test1</span> test2<BR>
</div><BR>
</P>

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 阜宁县| 临江市| 霍邱县| 富阳市| 深水埗区| 达孜县| 三穗县| 琼结县| 波密县| 蓬莱市| 芜湖市| 定陶县| 揭阳市| 五寨县| 辽中县| 策勒县| 海伦市| 辛集市| 策勒县| 垫江县| 北安市| 霍山县| 衡山县| 辽中县| 兴仁县| 大同县| 滦平县| 沾化县| 板桥市| 尼玛县| 建瓯市| 图木舒克市| 西乡县| 堆龙德庆县| 晋宁县| 杭州市| 佛坪县| 元谋县| 长子县| 互助| 夏河县|