redirect()
方法在
响应
interface returns a
响应
resulting in a redirect to the specified URL.
注意 : This is mainly relevant to the ServiceWorker API . A controlling service worker could intercept a page's request and redirect it as desired. This will actually lead to a real redirect if a service worker sends it upstream.
var response = Response.redirect(url, status);
url
The URL that the new response is to originate from.
status
可选
302
)。
A
响应
对象。
| 异常 | 解释 |
|---|---|
RangeError
|
The specified status is not a redirect status. |
TypeError
|
The specified URL is invalid. |
responseObj.redirect('https://www.example.com', 302);
| 规范 | 状态 | 注释 |
|---|---|---|
|
Fetch
The definition of 'redirect()' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
redirect
|
Chrome Yes | Edge 16 | Firefox Yes | IE No | Opera Yes | Safari Yes | WebView Android No | Chrome Android No | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android No |
完整支持
不支持
实验。期望将来行为有所改变。
响应
arrayBuffer()
blob()
clone()
error()
formData()
json()
redirect()
text()