网络编程
位置:首页>> 网络编程>> XML编程>> getAllResponseHeaders获取网页的http头信息代码

getAllResponseHeaders获取网页的http头信息代码

 来源:asp之家 发布时间:2010-03-31 14:31:00 

标签:getResponseHeader,http头,xmlhttp

使用xmlhttp中的getResponseHeader 从响应信息中获取指定的http头

strValue = oXMLHttpRequest.getAllResponseHeaders();

例子:

var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
xmlhttp.open("GET", "http://localhost/sample.xml", false);
xmlhttp.send();
alert(xmlhttp.getAllResponseHeaders());

输出由web服务器返回的http头信息,example:

Server:Microsoft-IIS/5.1
X-Powered-By:ASP.NET
Date:Sat, 07 Jun 2003 23:23:06 GMT
Content-Type:text/xml
Accept-Ranges:bytes
Last Modified:Sat, 06 Jun 2003 17:19:04 GMT
ETag:"a0e2eeba4f2cc31:97f"
Content-Length:9

备注

每个http头名称和值用冒号分割,并以\r\n结束。当send方法完成后才可调用该方法。

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com