Fork me on GitHub

ie

总结一下ie兼容性问题

css

  1. ie9及以下 a标签下的img会有黑色边框 => a img{border:0px;}
  2. a标签 点击后有 虚框 a{outline:none;}
  3. transform 要加啊前缀-ms-transform js=>msTransfrom
  4. input radio 在ie下样式难看,不和chrome一样,可以用lable方法写样式将input隐藏
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    .select-type label{
    position: relative;
    display: inline-block;
    padding-left: 20px;
    line-height: 20px;
    }
    .select-type label:before{
    position: absolute;
    content: '';
    height: 14px;
    width: 14px;
    border-radius: 50%;
    border:1px solid #666;
    box-sizing: border-box;
    background-color: #dedede;
    left:0;
    top:3px;
    }
    .select-type input:checked+label:after {
    position: absolute;
    content: '';
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    left: 3px;
    top:6px;
    }
1
2
3
4
5
6
<div class="select-type">
<input id="gnjp_single_trip" name="flighttype" type="radio" checked autocomplete="off">
<label for="gnjp_single_trip"><span>单程</span></label>
<input id="gnjp_round_trip" name="flighttype" type="radio" autocomplete="off">
<label for="gnjp_round_trip"><span>往返</span></label>
</div>

js

  1. toTop document.documentElement.scrollTop = document.body.scrollTop = 0;

  2. 事件绑定 attachEvent addEventListener

    1
    2
    3
    4
    5
    6
    7
    function bind(elem,type,fn){
    if(elem.addEventListener){
    elem.addEventListener(type,fn,false)
    }else{
    elem.attachEvent('on'+type,fn)
    }
    }
  3. ie9及以下不支持 classList

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    if (!("classList" in document.documentElement)) {
    Object.defineProperty(HTMLElement.prototype, 'classList', {
    get: function() {
    var self = this;
    function update(fn) {
    return function(value) {
    var classes = self.className.split(/\s+/g),
    index = classes.indexOf(value);
    fn(classes, index, value);
    self.className = classes.join(" ");
    }
    }
    return {
    add: update(function(classes, index, value) {
    if (!~index) classes.push(value);
    }),
    remove: update(function(classes, index) {
    if (~index) classes.splice(index, 1);
    }),
    toggle: update(function(classes, index, value) {
    if (~index)
    classes.splice(index, 1);
    else
    classes.push(value);
    }),
    contains: function(value) {
    return !!~self.className.split(/\s+/g).indexOf(value);
    },
    item: function(i) {
    return self.className.split(/\s+/g)[i] || null;
    }
    };
    }
    });
    }
  4. dataset ie9及以下不兼容

elem.getAttribute(‘data-index’);

  1. ie9不支持transition
-------------本文结束感谢您的阅读-------------