火狐FF和IE兼容下innerText的问题处理
来源:互联网 发布:对网络暴力的看法 编辑:程序博客网 时间:2024/05/02 20:46
第一种方式:
把上述JS放入jsp页面。
<script type="text/javascript">
function isIE()
{ //ie?
if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1)
return true;
else
return false;
}
if (!isIE())
{ //firefox innerText define
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"
? "/r/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;
});
}
</script>
第二种方式:
if(navigator.appName.indexOf("Explorer") > -1)采用if判断,火狐的就用textContent可以获取。
在火狐中会出现innerText空白,处理方法:obj.innerText.replace(/(^/s*)|(/s*$)/g,"")
- 火狐FF和IE兼容下innerText的问题处理
- innerText兼容火狐和IE
- innerText兼容火狐和IE
- IE和火狐的不兼容之innerText和textContent
- 火狐FF和IE兼容下margin-top无效的解决方法
- innerText 兼容火狐 ie浏览器
- IE和火狐兼容href的问题
- 关于IE和FF(火狐)下的页面获取色值的问题
- IE和FF的兼容
- 常用的兼容IE和火狐FF等浏览器的js方法
- 常用的兼容IE和火狐FF等浏览器的js方法
- JS在IE和FF下不兼容的问题及部分解决办法
- 关于JavaScript兼容FF和IE的方法(IE、FF下的srcElement属性)
- js在ie和ff下兼容的一点心得
- W3C下FF和IE兼容的一点小心德
- js下IE和FF的一些兼容写法总结
- IE 和ff css 兼容遇到的问题
- FF和IE兼容的捕获回车事件问题
- shell脚本中一些特殊符号
- UEStudio 开发ARM汇编语言自定义关键字高亮技巧
- 快速導出EXCEL --'WS_DOWNLOAD'
- 精辟,关于所谓“安全控件”
- 如何让 CXGRID 主从表任何时候只能展开一个组
- 火狐FF和IE兼容下innerText的问题处理
- 定制你自己的桌面--- launcher小觑
- android 传感器的使用
- 纯手工打造HTTP请求,淫领HTTP协议!~
- java软件工程师简介
- jQuery.extend 函数详解
- 雅虎给出的优化网站加载速度的34条法则
- J2SE学习笔记3 — Java基本语法(9)数组和枚举
- gcc命令详解