国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表

圖片精選

主站蜘蛛池模板: 报价| 澎湖县| 保靖县| 澄迈县| 肇东市| 城口县| 库伦旗| 吴川市| 潜江市| 雷波县| 铜川市| 耿马| 隆德县| 兴仁县| 青神县| 凤山县| 眉山市| 屯留县| 汕头市| 喀什市| 兴城市| 六盘水市| 元氏县| 吉安县| 云龙县| 涿鹿县| 寿宁县| 惠东县| 兖州市| 呼图壁县| 晋城| 金塔县| 南郑县| 西藏| 祁连县| 赫章县| 浙江省| 永宁县| 秦皇岛市| 抚宁县| 抚松县|