最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2013年08月07日 15:25:25   作者:  
在測試時(shí)發(fā)現(xiàn)firefox不支持innerText,該怎么辦呢?其實(shí)很簡單,本文為大家提供了一個解決方法,感興趣的朋友可以參考下,希望對大家有所幫助
js代碼:
復(fù)制代碼 代碼如下:

<script>
window.onload = function(){
<PRE class=javascript name="code">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 id="test"><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:red">test1</span> test2<BR>
</div><BR>
</P>

相關(guān)文章

最新評論

青阳县| 油尖旺区| 辰溪县| 土默特右旗| 天长市| 沅江市| 福泉市| 公主岭市| 镇沅| 南昌市| 恩平市| 阿坝| 汪清县| 安达市| 内乡县| 高陵县| 天气| 车险| 平定县| 葫芦岛市| 泌阳县| 北海市| 石林| 四平市| 南充市| 上思县| 读书| 电白县| 东丰县| 峨眉山市| 新乡县| 孙吴县| 甘肃省| 黔江区| 吉安市| 错那县| 桓台县| 石河子市| 永川市| 嘉义市| 固阳县|