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兼容问题
媒体查询不支持,解决方案
//页面head引入
<script type="text/javascript" src='respond.min.js'></script>bootstrap-datetimepicker.js 插件引用点选时间失效
代码如下图(已修正)选中部分在IE8及以前版本返回false,阻止输入框被选中
即可解决问题,也是够隐蔽的。
canvas兼容IE8
这种需求简直是无理取闹,但是还要解决啊。
//页面head引入
<script type="text/javascript" src="excanvas.js"></script>
基本就这么多了,后续更新。。。