function getStyle(obj,attr){
if(obj.currentStyle)
{return obj.currentStyle[attr]}
else{ return getComputedStyle(obj)[attr]
}
};

 
 
//style只能获取元素的内联样式,内部样式和外部样式使用style是获取不到的。  (这里我测试的在IE和FF下没有用,Chrome下有用,所有有歧义)
//currentStyle可以弥补style的不足,但是只适用于IE。
//getComputedStyle同currentStyle作用相同,但是适用于FF、opera、safari、chrome。

currentStyle getComputedStyle兼容的更多相关文章

  1. currentstyle和getComputedStyle兼容问题

    currentStyle:获取计算后的样式,也叫当前样式.终于样式. 长处:能够获取元素的终于样式,包含浏览器的默认值,而不像style仅仅能获取行间样式,所以更经常使用到. 注意:不能获取复合样式如 ...

  2. 函数语法:currentStyle、getComputedStyle兼容判断

    var oDiv = document.getElementById('aa'); if(oDiv.currentStyle){ var style = oDiv.currentStyle; aler ...

  3. 兼容获取元素当前样式 currentStyle || getComputedStyle

    function getStyle(ele, attr) { return ele.currentStyle ? ele.currentStyle[attr] : window.getComputed ...

  4. 用JS查看修改CSS样式(cssText,attribute('style'),currentStyle,getComputedStyle)

    CSS样式定义方法 大家都知道,在为HTML设置样式的时候,通常有三种方法:内联样式,内部样式表,外部样式表. 1.内联样式: 内联样式表就是在HTML元素中的行内直接添加style属性. <d ...

  5. 浅谈style.,currentStyle,getComputedStyle,getAttribute

    xxx为属性. ele为元素. 1.style.是针对于样式 在前面的一篇博客中我也有说到,ele.style.xxx; 通常用于赋值,赋值也是针对于行内样式,用它来取值的话,它只能取到内联样式. 今 ...

  6. 元素高度、宽度获取 style currentStyle getComputedStyle getBoundingClientRect

    1.示例代码 (1)html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  7. JS---获取元素计算后的样式属性值 (getComputedStyle)---兼容函数

    获取计算后的样式属性----获取一个元素任意一个样式属性值 获取元素距离左边位置的值 会有如下兼容性问题: my$("btn").onclick = function () { / ...

  8. style currentStyle getComputedStyle的区别和用法

    先介绍下层叠样式表的三种形式: 1.内联样式,在html标签中style属性设置. <p style="color:#f90">内联样式</p> 2.嵌入样 ...

  9. currentStyle&getComputedStyle获取属性

    方法如下: function getStyle(obj,attr){ if(obj.currentStyle){ return obj.currentStyle[attr]; // IE 中的方法 } ...

随机推荐

  1. amazon lightsail

    https://51.ruyo.net/6038.html https://aws.amazon.com/cn/lightsail/

  2. CentOS 7.2 安装Gerrit 2.14.6

    1.环境 本文使用VMWare虚拟机进行实验. 2核CPU,4GB内存,20GB硬盘,IP:192.168.159.131 CentOS 7.2最小安装(CentOS-7-x86_64-Minimal ...

  3. POJ2251 Dungeon Master —— BFS

    题目链接:http://poj.org/problem?id=2251 Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total S ...

  4. magento导入数据的方法

    导入演示数据 分两种情况处理. 如果你是用composer方式安装的 非常简单,二行命令搞定:在项目根目录下执行.我们的是在/var/www/magento2/下面. 安装演示数据 php bin/m ...

  5. Tomcat的一些问题

    首先设置好TOMCAT环境变量(如何设置?) 1.用Servlet发现每次改动Servlet都要重启Tomcat才能生效!!!搞死爹了!! 可以选择shutdown命令或者直接叉掉汤姆猫窗口!!!然后 ...

  6. HTTP错误code大全

    100 - Continue 101 - Switching Protocols Top Success Codes 200 - OK 201 - Created 202 - Accepted 203 ...

  7. OkHttp解析

    今天花了一天时间研究了下OkHttp3的内部原理,记录在此处以便后期查阅 我们先来看下基本的使用方式: public void sendHttpRequest(String url,Callback ...

  8. ObjectARX学习笔记

    http://blog.csdn.net/jangdong/article/category/1642265/3 http://blog.csdn.net/u011331383/article/cat ...

  9. HK算法模板+小优化(跑的快一点点)

    HUST 2604 #include <iostream> #include <cstdlib> #include <cstdio> #include <cs ...

  10. python __builtins__ set类 (60)

    60.'set',  转换为集合类型 class set(object) | set() -> new empty set object | set(iterable) -> new se ...