rut*_*iwi 5 javascript google-chrome xmlhttprequest google-translate ios
这是一个非常超现实的问题。当我在 iOS 上使用 chrome 时,我无法设置 xhr.timeout。它抛出InvalidAccessError: The object does not support the operation or argument.
您可以通过访问此处重现它:https : //viktorh.net/chromebug.html 在 iOS 上的 chrome 中。然后使用 chrome 的内置翻译器翻译页面 - 现在调用 XHR.timeout 失败。
有谁知道为什么会这样?如果这是 chrome 中的错误,有人知道解决方法吗?你在哪里可以报告这样的问题?
这很奇怪。我可以重现这个问题,它看起来确实像是 iOS 上 Chrome 中的一个小错误。默认情况下,XMLHttpRequest 有无限超时,但您可以通过手动创建超时来中止请求来解决此问题。为了安全起见,当请求成功或失败时,我会在负载端清除此超时。像这样的东西:
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
var timeout;
oReq.addEventListener("loadend", function() {
// request over - clear timeout
clearTimeout(timeout);
});
// set a timeout to abort the request
timeout = setTimeout(function() {
oReq.abort();
// we timed out
},20000);
oReq.open("GET", "/");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |