zoukankan      html  css  js  c++  java
  • 近段时间js的兼容性问题的汇总

    1.选择器的兼容问题
    所有的浏览器都支持
    getElementById getElemnetsByTagName
    IE8不支持
    getElementsByClassName querySelector querySelectorAll


    2.获取行间style时的兼容性问题
    obj.style.attr这种格式只能获取到行间style,非行间style就无法获取到
    所以在Google与Firefox下可以使用:
    getComputedStyle(对象,false)[样式名]。
    在其他浏览器使用:
    obj.currentStyle[样式名]。
    两者兼容性问题按如下方法解决
    function getStyle(obj,attr){
    if(obj.currentStyle){
    return obj.currentStyle[attr];
    }else{
    return getComputedStyle(obj,false)[attr];
    }
    }

    3.dom操作的兼容性问题
    在google与Firefox下支持的操作,在IE中却不支持
    previousElementSibling, nextElementSibling
    firstElementChild, lastElementChild
    这些对应的操作,在IE中需要使用以下
    previousSibling, nextSibling
    firstChild, lastChild

    4.jq的兼容性问题
    jq主版本号兼容需要注意:
    1开头的支持ie6, ie7, ie8
    2开头的支持ie8以上
    3开头的支持的就更高了

  • 相关阅读:
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    C++生产和使用的临时对象
    RecyclerView0基于使用
    Docker创建MySQL集装箱
  • 原文地址:https://www.cnblogs.com/momomiji/p/7642703.html
Copyright © 2011-2022 走看看