js代码:
<script>
window.onload = function(){
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;
}
);
};
var test = document.getElementById("test");
var innerText_s = test.innerText;
if( innerText_s == undefined ){
alert( test.textContent ); // firefox
}else{
alert( test.innerText);
}; } </script>

html代码

<div id="test">
      <span style="color:red">test1</span> test2
</div>

最新文章

  1. vs2012 打开解决方案崩溃或者点击项目崩溃
  2. 通过PHP自带的$_SERVER判断 手机访问网站自动跳转到手机版
  3. Java_JAVA6动态编译的问题
  4. Serializable 和 Parcelable 区别
  5. java.lang.NoClassDefFoundError: javax/transaction/UserTransaction
  6. Mysql统计同一字段不同值的个数
  7. scrapy1.1入门用例简介-2
  8. tomcat的集群配置
  9. directory not found for option
  10. js之date()对象
  11. FPGA实现“打字机”(VGA &amp; UART)
  12. 2017-07-12(touch df du)
  13. jvm内存查看与分析工具
  14. [USACO12MAR] 花盆Flowerpot
  15. webpack学习笔记--配置plugins
  16. [转] babel-plugin-react-css-modules配置
  17. Java 中的 IO 与 socket 编程 [ 复习 ]
  18. python多线程学习二
  19. @Scheduled 定时
  20. python+selenium六:等待相关

热门文章

  1. js实现数据视图双向绑定原理
  2. ipad webapp禁止长按选择
  3. 如何用python解析mysqldump文件
  4. Centos7配置vsftpd3.0.2
  5. MySQL下concat函数中null值问题
  6. centos7.3 chrome 安装
  7. HBase(二)CentOS7.5搭建HBase1.2.6HA集群
  8. D - Round Subset codeforces837d
  9. loadrunner学习笔记之参数设置
  10. 005 Hadoop的三种模式区别