2010年03月31日Archive for
Web前端开发QQ群 110939958-业余程序员
扩展一个函数的延时调用 Function.prototype.delay = function(n, thisObj, args) {
var me = this;
args = args instanceof Array ? args : [];
var f = function() {
me.apply(thisObj || window, args);
};
window.setTimeout(f, n);
}
//示例
function f() {
alert("hi");
}
alert("两秒之后弹出");
f.delay(2000);
注意第三个是参数数组
第一次用Live Writer写日志,呵呵