IE6~IE8不支持Function原型的bind()方法,所以对其进行扩展。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
26var Iflat = Iflat || {};
Iflat.Browser = {
extend: = {
ieFuncBind: function() {
if(!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if(typeof this !== 'function') {
// closest thing possible to the ECMAScipt 5
// internal IsCallable function
throw new TypeError('What is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1);
var fToBind = this;
var fNOP = function(){};
var fBound = function() {
return fToBind.apply(this instanceof fNOP ? this : oThis,
aArgs.contac(Array.prototype.slice.call(arguments)));
}
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
eturn fBound;
};
}
}
}
}
主页 | 分类 | 标签 |
|