gpt4 book ai didi

javascript - iOS chrome - 翻译页面时 xhr.timeout 抛出错误

转载 作者:行者123 更新时间:2023-12-03 17:09:16 24 4
gpt4 key购买 nike

这是一个非常超现实的问题。当我在 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", "/");

关于javascript - iOS chrome - 翻译页面时 xhr.timeout 抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66782572/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com