setTimeOut如何传递参数

来源:互联网 发布:百度云 知乎周刊mobi 编辑:程序博客网 时间:2024/05/21 20:26

<script type="text/javascript">
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
 if(typeof fRef == 'function'){
  var argu = Array.prototype.slice.call(arguments,2);
  var f = (function(){ fRef.apply(null, argu); });
  return _st(f, mDelay);
 }
 return _st(fRef,mDelay);
}

function test(x){
 alert(x);
}
window.setTimeout(test,1000,'fason');
</script>