解决firefox不支持innerText的办法
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>
解决firefox不支持innerText的办法的更多相关文章
- jquery easyui-linkButton获取和设置按钮text并且解决火狐不支持innerText的方法
<a href="javascript:test" id="btn" class="easyui-linkbutton" iconCl ...
- FireFox不支持InnerText的解决方法
innerText和InnerHTML是非常实用的一个属性,然而在FireFox中不支持此属性,可能是因为考虑到网页的安全性.这样一来为开发者带来了不少麻烦.FireFox中也提供了另外一个属性inn ...
- 解决firefox不支持-webkit-line-clamp属性
转载声明: 请注明本文引用自http://www.cnblogs.com/guolizhi/ css中-webkit-line-clamp这个属性表示超过指定行的文本隐藏并且会在结尾加上...号,用起 ...
- 解决ie6不支持position: fixed;导致无法滚动的办法
<div id="im" style="top: 100px; position: fixed; left: 5px; border: 3px solid #006 ...
- 解决selenium不支持firefox低版本的问题
解决selenium不支持firefox低版本的问题 在火狐浏览器升级后,突然发现webdriver运行脚本的时候不能调出火狐浏览器了,并报错WebDriverException:Message:'C ...
- 兼容firefox,ie,谷歌,阻止浏览器冒泡事件,Firefox不支持event解决方法
兼容firefox,ie,谷歌,阻止浏览器冒泡事件,Firefox不支持event解决方法 // 获取事件function getEvent(){ if(window.event) {return w ...
- firefox并不支持selectSingleNode和selectNodes的解决方法
转自:http://qsrock.iteye.com/blog/209585 function test(){ var perid = document.thisForm.PerID.value; v ...
- 低版本Firefox支持innerText属性兼容方法
FireFox支持innerText属性了,很遗憾是44.0.2版本以下还需要兼容处理. 方法一: innerHTML是符合W3C标准的属性,而innerText只适用于IE浏览器,因此,尽可能地去使 ...
- 解决window.showModalDialog在Firefox无法支持
在网页程序中,有时我们会希望使用者按下按钮后开启一个保持在原窗口前方的子窗口,而在IE中,我们可以使用showModalDialog来达成,语法如下 : vReturnValue = window.s ...
随机推荐
- linux下/var/run目录下.pid文件的作用
1.pid文件的内容用cat命令查看,可以看到内容只有一行,记录了该进程的ID 2.pid文件的作用防止启动多个进程副本 3.pid文件的原理进程运行后会给.pid文件加一个文件锁,只有获得该锁的进程 ...
- Mac ssh
mac的终端默认在打开一个新的tab/window的时候需要重新输入ssh的密码, 很不方便.本文完成在mac中设置,实现secureCRT/xshell里的克隆会话功能, 即新开一个terminal ...
- Web Api - HttpMessageHandler 学习
参考: 1.http://www.cnblogs.com/chenboyi081/p/4995252.html 2.http://www.cnblogs.com/r01cn/archive/2012/ ...
- 【小程序开发】购物车加减几件demo
<!-- 主容器 --> <view class="stepper"> <!-- 减号 --> <text class="{{m ...
- xgboost gbdt特征点分烈点
lightGBM与XGBoost的区别:(来源于:http://baijiahao.baidu.com/s?id=1588002707760744935&wfr=spider&for= ...
- Spring MVC参数注入注意事项
1.类参数名不能出现‘name’ 2.需提供默认的无参构造
- java基础44 IO流技术(输出字节流/缓冲输出字节流)和异常处理
一.输出字节流 输出字节流的体系: -------| OutputStream:所有输出字节流的基类(抽象类) ----------| FileOutputStream:向文件输出数据的输出字节流(把 ...
- emacs设置了单例模式后无法设定文件关联解决办法
emacs设置单例模式的本质就是使用下列参数启动: C:\emacs-24.5\bin\emacsclientw.exe --no-wait --alternate-editor="C:\e ...
- bash常用快捷键和命令
在使用Linux的时候,最常见的终端解释器就是bash了.bash下有很多技巧,我知道这么几个: 0.关于按键模式bash默认的按键模式是emacs风格的.你也可以通过set -i vi设定为vi风格 ...
- VS 2015 序列号/密钥/企业版/专业版
专业版:HMGNV-WCYXV-X7G9W-YCX63-B98R2企业版:HM6NR-QXX7C-DFW2Y-8B82K-WTYJV