asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0

<script>
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');

//call,apply需要高版本支持,低版本的call,apply实现不在这罗嗦了~~
</script>

 

////////////////////////////////////////////////////////////////////////////////////////////////////

<script>
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,y){
    alert(x+y);
}
window.setTimeout(test,1000,'fason','YYYY');
</script>

 

posted on 2006-04-03 15:40 汪杰 阅读(434) 评论(2)  编辑 收藏 引用 所属分类: javascripthengxing网站js

FeedBack:
# re: 在setTimeout中传递函数参数
2006-08-18 23:47 | 汪杰
<html>
<head>
<script language="javascript">
function test(n,m){
alert(n+"\n"+m);
}
//var _st = window.setInterval;
var process = function(fRef, mDelay) {
if (typeof fRef == 'function') {
var argu = Array.prototype.slice.call(arguments,2);
var f = (function(){ fRef.apply(null,argu); });
return window.setInterval(f, mDelay);
}
return window.setInterval(fRef,mDelay);
}

function fu(n,m)
{
process(test,1000,n,m);
}
</script>
</head>
<body>
<button onclick="fu('fk','you')">just do it</button>
</body>
</html>  回复  更多评论
  
# re: 在setTimeout中传递函数参数
2007-09-22 23:56 | tianya
痛苦的时候要学会坚强不要官别人说什么走自己的路不管别人说什么天无决人之路。天涯对爱说永别‘
相信自己你是再棒的  回复  更多评论
  
只有注册用户登录后才能发表评论。

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 459290
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜