WindowTimers 接口包含了四个用来设定和清除定时器的实用方法。
事实上,类型为 WindowTimers 的对象并不存在,它一般由上下文对象 Window(在普通的浏览域中)或者 WorkerGlobalScope(在 Web Workers 中)来实现。
属性
这个接口没有定义也没有继承任何属性。
方法
除下面的自身方法外,这个接口没有继承任何方法。
WindowTimers.clearInterval()- 取消掉通过
WindowTimers.setInterval()方法设定的重复执行任务。 WindowTimers.clearTimeout()- 取消掉通过
WindowTimers.setTimeout()方法设定的延时执行任务。 WindowTimers.setInterval()- 设定一个每隔指定毫秒执行一次的重复执行任务。
WindowTimers.setTimeout()- 设定一个在指定毫秒后执行一次的延时执行任务。
规范
| 规范名称 | 规范状态 | 备注 |
|---|---|---|
| WHATWG HTML Living Standard WindowTimers |
Living Standard | |
| HTML5.1 WindowTimers |
Working Draft | |
| HTML5 WindowTimers |
Recommendation |
浏览器兼容性
| Feature | Firefox (Gecko) | Chrome | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 1.0 (1.7 or earlier) | 1.0 | 4.0 | 4.0 | 1.0 |
| Feature | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | 1.0 (1) | (Yes) | (Yes) | (Yes) | (Yes) |