has()
方法在
头
interface returns a boolean stating whether a
头
object contains a certain header.
For security reasons, some headers can only be controlled by the user agent. These headers include the forbidden header names and forbidden response header names .
myHeaders.has(name);
名称
TypeError
.
A
布尔
.
Creating an empty
头
object is simple:
var myHeaders = new Headers(); // Currently empty
You could add a header to this using
Headers.append
, then test for the existence of it using
has()
:
myHeaders.append('Content-Type', 'image/jpeg');
myHeaders.has('Content-Type'); // Returns true
myHeaders.has('Accept-Encoding'); // Returns false
| 规范 | 状态 | 注释 |
|---|---|---|
|
Fetch
The definition of 'has()' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
has
|
Chrome
42
|
Edge 14 |
Firefox
39
|
IE No |
Opera
29
|
Safari No | WebView Android 42 |
Chrome Android
42
|
Firefox Android No |
Opera Android
29
|
Safari iOS No | Samsung Internet Android 4.0 |
完整支持
不支持
实验。期望将来行为有所改变。
用户必须明确启用此特征。