timeout

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

当进度由于预定时间到期而终止时,会触发 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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
timeout event

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见