IE8兼容之大杂烩

IE8兼容之大杂烩(你需要的可能都在这)

IE8不支持的方法兼容

!(function () {
    if (!Object.create) {
        Object.create = (function(){
            function F(){}
            return function(o){
                if (arguments.length != 1) {
                    throw new Error('Object.create implementation only accepts one parameter.');
                }
                F.prototype = o;
                return new F()
            }
        })()
    }
    if (!Function.prototype.bind) {
        Function.prototype.bind = function (oThis) {
            if (typeof this !== "function") {
                throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
            }
            var aArgs = Array.prototype.slice.call(arguments, 1),
                fToBind = this,
                fNOP = function () {
                },
                fBound = function () {
                    return fToBind.apply(this instanceof fNOP && oThis
                        ? this
                        : oThis,
                        aArgs.concat(Array.prototype.slice.call(arguments)));
                };
            fNOP.prototype = this.prototype;
            fBound.prototype = new fNOP();
            return fBound;
        };
    }
   // 这里借用jQuery的$.trim()方法解决,所有这段js必须在jQuery之后加载
    if (!String.prototype.trim) {
        String.prototype.trim = function () {
            return $.trim(this);
        }
    }
    if (!String.prototype.indexOf) {
        String.prototype.indexOf = function (s) {
            return $.inArray(s,this);
        }
    }

    if (!Array.prototype.indexOf) {
        //添加数组IndexOf方法
        if (!Array.prototype.indexOf){
            Array.prototype.indexOf = function(elt /*, from*/){
                var len = this.length >>> 0;

                var from = Number(arguments[1]) || 0;
                from = (from < 0)
                    ? Math.ceil(from)
                    : Math.floor(from);
                if (from < 0)
                    from += len;

                for (; from < len; from++){
                    if (from in this && this[from] === elt)
                        return from;
                }
                return -1;
            };
        }
    }

    var ConsoleLog = true;// 是否输出日志
    if (!window.console) {
        window.console = {
            log: function () {
            }
        };
    }
    window.console = window.console || {};
    console.log || (console.log = opera.postError);
    if (!ConsoleLog) {
        window.console.log = function () {
        };
    }
})();

bootstrap IE8兼容问题

  1. 媒体查询不支持,解决方案

    //页面head引入
    <script type="text/javascript" src='respond.min.js'></script>

  2. bootstrap-datetimepicker.js 插件引用点选时间失效

代码如下图(已修正)选中部分在IE8及以前版本返回false,阻止输入框被选中
即可解决问题,也是够隐蔽的。

这里写图片描述

canvas兼容IE8

这种需求简直是无理取闹,但是还要解决啊。
//页面head引入
<script type="text/javascript" src="excanvas.js"></script>

excanvas.js


基本就这么多了,后续更新。。。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值