// JavaScript Document
var easyUI =
{
// easyUI base support
fpbind : function()
{
// function bind to object
if( ! Function.prototype.bind)
{
Function.prototype.bind = function(obj) //obj 有什么用 没有见到何处在引用此对象啊
{
var owner = this, args = Array.prototype.slice.call(arguments), callobj = Array.prototype.shift.call(args);
return function(e)
{
e = e || top.window.event || window.event;
owner.apply(callobj, args.concat([e]));
}
;
}
;
}
}
var easyUI =
{
// easyUI base support
fpbind : function()
{
// function bind to object
if( ! Function.prototype.bind)
{
Function.prototype.bind = function(obj) //obj 有什么用 没有见到何处在引用此对象啊
{
var owner = this, args = Array.prototype.slice.call(arguments), callobj = Array.prototype.shift.call(args);
return function(e)
{
e = e || top.window.event || window.event;
owner.apply(callobj, args.concat([e]));
}
;
}
;
}
}
解决方案 »
- 请问,原型对象
- 关于IFRAME框架的问题!!
- 请教一个循环在页面建立div的问题
- 关于梅花雪树,怎样像csdn树当鼠标移上时高亮
- 散文,进我的群,主要是论论JS,AJAX 21295415
- 求一个超强的JavaScript混淆器,要求能对含多个JS的项目进行加扰
- 谁来挑战一个菜单,思路也行,菜单项数据是从数据库读取的,不定的,想实现的效果如下..
- 100 怎么用javascript禁止IE刷新??
- 十万火急!为什么弹出窗口中的控件不响应事件处理程序?而正常打开它却没什么问题!~~请高手解惑!!
- 导入项目,部署Tomcat时报错,求解决。。
- 崩溃中……,js获得图片大小,查了一段代码却死循环,紧急求助
- jsp删除表中数据
Function.prototype.bind = function(obj)
{
var owner = this, args = Array.prototype.slice.call(arguments), callobj = Array.prototype.shift.call(args);
return function(e) {
e = e || top.window.event || window.event;
owner.apply(callobj, args.concat([e]));
}
} var a = function() {
alert(this.tagName);
} var b = function() {
alert(this.tagName);
} .bind(document.getElementById('divID')); var c = function (cc) {
alert(cc);
}.bind(this, 'abcd'); a(); //显示undefined
a.call(document.body); //显示BODY
b(); //显示DIV
c(); //显示abcd
// JavaScript Document
var easyUI =
{
// easyUI base support
fpbind : function()
{
// function bind to object
if( ! Function.prototype.bind)
{
Function.prototype.bind = function(obj) //obj,this scope,callobj就是它,args是后面跟的参数。
{
var owner = this, args = Array.prototype.slice.call(arguments), callobj = Array.prototype.shift.call(args);
return function(e)
{
e = e || top.window.event || window.event;
owner.apply(callobj, args.concat([e]));//在最终执行的函数里最后一个参数会是event对象。
}
;
}
;
}
}
等价于
Array.prototype.shift.call(args)// 获取arguments中的第一个参数(arguments[0])
Function.prototype.bind = function(obj)
{
var owner = this, args = Array.prototype.slice.call(arguments), callobj = Array.prototype.shift.call(args);
return function(e) {
e = e || top.window.event || window.event;
owner.apply(callobj, args.concat([e]));
}
} var a = function() {
alert(this.tagName);
} var b = function() {
alert(this.tagName);
} .bind(document.getElementById('divID')); var c = function (cc) {
alert(cc);
}.bind(this, 'abcd'); a(); //显示undefined
a.call(document.body); //显示BODY
b(); //显示DIV
c(); //显示abcd