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

首頁 > 編程 > JavaScript > 正文

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

2019-11-20 22:26:35
字體:
供稿:網(wǎng)友
js代碼:
復制代碼 代碼如下:

<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>
      <span style="color:red">test1</span> test2<BR>
</div><BR>
</P>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 祁阳县| 江源县| 嘉禾县| 普兰店市| 河间市| 彰化县| 淄博市| 上饶市| 社会| 黎平县| 博客| 陕西省| 郧西县| 南宁市| 腾冲县| 靖安县| 黑河市| 彭水| 神农架林区| 马鞍山市| 藁城市| 宁远县| 洪雅县| 岳普湖县| 佛坪县| 股票| 百色市| 香格里拉县| 保靖县| 什邡市| 绿春县| 桂阳县| 谷城县| 盘锦市| 阳谷县| 昌平区| 慈利县| 个旧市| 姚安县| 毕节市| 拉萨市|