此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

timeout

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

当进度由于预定时间到期而终止时,会触发 timeout 事件。

冒泡
可取消
目标对象 XMLHttpRequest
接口 ProgressEvent

示例

js
var client = new XMLHttpRequest();
client.open("GET", "http://www.example.org/example.txt");
client.ontimeout = function (e) {
  console.error("Timeout!!");
};
client.send();

继承

timeout 事件实现了 ProgressEvent 接口,它继承自 Event — 它拥有在这个接口上定义的属性和方法。

规范

Specification
XMLHttpRequest
# event-xhr-timeout
XMLHttpRequest
# handler-xhr-ontimeout

浏览器兼容性

参见