emu in blogjava

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  171 随笔 :: 103 文章 :: 1052 评论 :: 2 Trackbacks

 

if ( typeof (Function.prototype.apply) != " function " )
{
  Function.prototype.apply 
=   function (obj, argu)
  {
    
var  s;
    
if (obj)
    {
      obj.constructor.prototype._caller
= this ;
      s 
=   " obj._caller " ;
    }
    
else  s  =   " this " ;
    
var  a = [];
    
for ( var  i = 0 ; i < argu.length; i ++ )
      a[i] 
=   " argu[ " +  i  + " ] " ;
    
return  eval(s  + " ( " +  a.join( " , " + " ); " );
  };
  Function.prototype.call  
=   function (obj)
  {
    
var  a = [];
    
for ( var  i = 1 ; i < arguments.length; i ++ )
      a[i
- 1 ] = arguments[i];
    
return   this .apply(obj, a);
  }; 
posted on 2006-05-23 18:33 emu 阅读(884) 评论(1)  编辑  收藏

评论

# re: fason 的 apply & call for IE5 2006-06-20 16:12 Twinsen
cool,不错的说  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: