火狐下实现currentStyle方法(获取当前元素样式)
来源:互联网 发布:中超后卫数据 编辑:程序博客网 时间:2024/06/04 20:07
<script type="text/javascript">
(function (bool) {
//严重感谢M2前辈
if (bool) {
HTMLElement.prototype.__defineGetter__("currentStyle", function () {
//getComputedStyle方法参数一是目标对象,参数二是具体属性。。。把注释对换下就知道了。。
//return this.ownerDocument.defaultView.getComputedStyle(this, ":first-line");
return this.ownerDocument.defaultView.getComputedStyle(this, null);
});
}
})(/Firefox/.test(window.navigator.userAgent));
</script>
<style type="text/css">
div {
color:#000000;
}
div:first-line {
color:#0000FF;
}
</style>
<div onclick="alert(this.currentStyle.color)">DIV对象<br />第二行</div>
(function (bool) {
//严重感谢M2前辈
if (bool) {
HTMLElement.prototype.__defineGetter__("currentStyle", function () {
//getComputedStyle方法参数一是目标对象,参数二是具体属性。。。把注释对换下就知道了。。
//return this.ownerDocument.defaultView.getComputedStyle(this, ":first-line");
return this.ownerDocument.defaultView.getComputedStyle(this, null);
});
}
})(/Firefox/.test(window.navigator.userAgent));
</script>
<style type="text/css">
div {
color:#000000;
}
div:first-line {
color:#0000FF;
}
</style>
<div onclick="alert(this.currentStyle.color)">DIV对象<br />第二行</div>
- 火狐下实现currentStyle方法(获取当前元素样式)
- getComputedStyle方法与currentStyle属性获取元素样式
- 如何用js获取元素样式(get.ComputedStyle()和currentStyle方法)
- FF下实现currentStyle方法
- 获取样式currentstyle(),getComputedStyle()
- 用currentStyle和getCompusedStyle获取元素的样式
- 获取元素样式方式 style、getcomputedstyle与 currentStyle 的用法
- dedecms多级导航支持currentstyle当前样式的方法
- 获取样式 currentStyle与getComputedStyle
- JS获取CSS样式(style/getComputedStyle/currentStyle)
- 火狐下获取不到当前文档高度
- getComputedStyle与currentStyle获取样式(style/class)
- javascript的样式获取--getComputedStyle、currentStyle、style
- getComputedStyle与currentStyle获取样式(style/class)
- getComputedStyle与currentStyle获取样式(style/class)
- 火狐下获取选中的checkbox方法
- 火狐下获取自定义属性的方法
- 用currentstyle为当前栏目增加一些样式
- Linux内核中链表和散列表的实现原理揭秘
- jdbc连接数据库和使用
- new与override的区别
- 打开网页
- oracle 排序取前几位 partition by
- 火狐下实现currentStyle方法(获取当前元素样式)
- C#语言----继承(学习总结)
- SHA|MessageDigest
- xen toolstack - xen api
- 根据xsd生成xml文档
- Transfer与Redirect区别
- windows 核心编程学习笔记3
- Spinner(1): 由SDK引发的问题
- 春江赞