blob: d940a603bf12f9559a85cfa0f119c8e5680b3409 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
---
title: Response.redirect()
slug: Web/API/Response/redirect
translation_of: Web/API/Response/redirect
---
<div>{{APIRef("Fetch")}}</div>
<p>{{domxref("Response")}} インターフェイスの <strong><code>redirect()</code></strong> メソッドは、指定されたURLへのレダイレクトをもたらす <code>Response</code> を返します。</p>
<div class="note">
<p><strong>Note</strong>: これは主に <a href="/ja/docs/Web/API/ServiceWorker_API">ServiceWorker API</a> に関連しています。制御service worker は、ページのリクエストを中断し、必要に応じてリダイレクトできます。もし Service worker が上流に送信を行うと、実際に本当のリダイレクトが発生します。</p>
</div>
<h2 id="構文">構文</h2>
<pre class="syntaxbox notranslate">var <em>response</em> = Response.redirect(<em>url</em>, <em>status</em>);</pre>
<h3 id="引数">引数</h3>
<dl>
<dt><code>url</code></dt>
<dd>新しい reponse の発信元URL。</dd>
<dt><code>status</code> {{optional_inline}}</dt>
<dd>response のオプションのステータスコード (例 <code>302</code> )</dd>
</dl>
<h3 id="返り値">返り値</h3>
<p>{{domxref("Response")}} オブジェクト</p>
<h3 id="例外">例外</h3>
<table class="standard-table">
<thead>
<tr>
<th scope="col">例外</th>
<th scope="col">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>RangeError</code></td>
<td>指定されたステータスはリダイレクトステータスではありません。</td>
</tr>
<tr>
<td><code>TypeError</code></td>
<td>指定されたURLは無効です。</td>
</tr>
</tbody>
</table>
<h2 id="例">例</h2>
<pre class="brush: js notranslate">responseObj.redirect('https://www.example.com', 302);</pre>
<h2 id="仕様">仕様</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">仕様</th>
<th scope="col">状態</th>
<th scope="col">コメント</th>
</tr>
<tr>
<td>{{SpecName('Fetch','#dom-response-redirect','redirect()')}}</td>
<td>{{Spec2('Fetch')}}</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="ブラウザー実装状況">ブラウザー実装状況</h2>
<p>{{Compat("api.Response.redirect")}}</p>
<h2 id="関連項目">関連項目</h2>
<ul>
<li><a href="/ja/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li>
<li><a href="/ja/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li>
<li><a href="/ja/docs/Web/HTTP">HTTP</a></li>
</ul>
|