【发布时间】:2011-08-18 11:08:39
【问题描述】:
假设我有以下 JavaScript 代码(在全局上下文中):
var t = setTimeout(f, a); // f is an arbitrary function, a an arbitrary timeout
现在可以取消设置的超时:
clearTimeout(t);
但是是否也可以在正常触发之前执行超时?
例如:
var func = getFunctionFromTimeout(t); // Does a function like this exists?
clearTimeout(t);
func();
或
executeAndClearTimeout(t); // Does this one?
【问题讨论】:
标签: javascript timeout