Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

XMLHttpRequest.setRequestHeader()

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

Draft
This page is not complete.


The XMLHttpRequest.setRequestHeader() method sets the value of an HTTP request header. You must call setRequestHeader()after open(), but before send(). If this method is called several times with the same header, the values are merged into one single request header.

void setRequestHeader(
   DOMString header,
   DOMString value
);

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.

Parameters
header
The name of the header whose value is to be set.
value
The value to set as the body of the header.

Specifications

Specification Status Comment
XMLHttpRequest
The definition of 'setRequestHeader()' in that specification.
Living Standard WHATWG living standard

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1 ? 5[1]
7
(Yes) 1.2
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 1.0 (Yes) ? ? ?

[1] This feature was implemented via ActiveXObject(). Internet Explorer implements the standard XMLHttpRequest since version 7.

See also

Using XMLHttpRequest

文档标签和贡献者

 此页面的贡献者: MashKao, jsx
 最后编辑者: MashKao,