过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
useFinalURL
特性为
响应
interface contains a boolean stating whether this is the final URL of the response.
This property applies only to
ServiceWorkers
. In other contexts it will return
undefined
.
var isfinalURL = Response.useFinalURL;
A
布尔
indicating whether or not the URL is final rather than a redirect.
Consider a script residing in page
index.html
:
fetch('/test').then((r) => console.log(r.url))
test.html
is being controlled by the service worker
sw.js
:
onfetch = (e) => {
e.respondWith(fetch('/page2').then((r) => {
r.usefinalURL = true;
return r;
})
}
The output will be
/page2
和不
/test
in
index.html
, since setting the
usefinalURL
means that the response's URL is not set to request's URL.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
useFinalURL
弃用
|
Chrome
42
|
Edge ≤18 |
Firefox
39
|
IE No |
Opera
29
|
Safari No | WebView Android No | Chrome Android No |
Firefox Android
39
|
Opera Android
29
|
Safari iOS No | Samsung Internet Android No |
完整支持
不支持
实验。期望将来行为有所改变。
弃用。不要用于新网站。
用户必须明确启用此特征。
响应
body
bodyUsed
headers
ok
redirected
status
statusText
type
url
useFinalURL