DelphiFAQ Home Search:

How can I read the HTTP response headers of the page?


comments20 comments. Current rating: 3 stars (15 votes). Leave comments and/ or rate it.

The browser object model doesn't provide access to these headers but in IE 5 and newer you have an ActiveX Object Microsoft.XMLDOM which can request the page and return the headers as shown below:

<script language="JavaScript" type="text/javascript">
var http = new ActiveXObject('Microsoft.XMLHTTP');

// display headers of current document:'HEAD', location.href, false);

// or display headers of'HEAD', '', false);



You are on page 1 of 2, other pages: [1] 2
2008-04-18, 01:34:48
anonymous from India  
How to use this script? can you tell the complete procedure
2008-05-19, 15:51:12
anonymous from United States  
How to use it, depends on what you need it to do.
It fires off an AJAX request to the server to fetch just the headers for
the current page, so if you're on a page that has submitted some data or something
you'd get a duplicate request to the server.

If you just want to look at the headers for a given page really quickly int
the browser you can do it like this. (Adapted from above)
Copy the following string, and paste it into the location bar of your IE browser (doesn't
work in FF).
javascript:var http = new ActiveXObject('Microsoft.XMLHTTP');'HEAD', location.href, false);http.send();alert(http.getAllResponseHeaders())

It'll fetch the headers for the page you're sitting on, and display them.
2008-06-20, 03:11:38
[hidden] from Yangon, Myanmar  
2009-07-06, 02:38:19
anonymous from Denpasar, Indonesia  
The script author seems to have forgotten something in the 'send' method:


Works a lot better like that. Hope it helps!
2009-12-24, 21:02:32
Thank you for the script. But when I run it, I get error on remote url. It's says I didn't have any access.
2009-12-24, 21:16:57
anonymous from China  
Hello, I look up in, and find out open method: open('method','URL',async,'uname','pswd')

like your last script, open the remote url, if I don't know password, the last parm, how can I get the header from a remote url?

Thank for you help anyway.
2012-05-07, 18:53:31   (updated: 2012-05-07, 18:54:04)
anonymous from India  
Great script for IE thanks..
2017-11-27, 19:51:19
anonymous from Indonesia  
2020-06-23, 11:04:59
Santo from United Kingdom  
Hi there colleagues, how is the whole thing, and what you would like
to say on the topic of this piece of writing, in my view its genuinely remarkable in support of me.
2020-06-28, 21:44:27
Earnestine from Den Haag, Netherlands  
2020-06-30, 22:10:30
Debora from Germany  
generic viagra coupon
2020-07-03, 02:05:26
clomid generic
2020-07-03, 04:36:38
can you buy cialis without a prescription
2020-07-03, 16:41:42
Mario from Ukraine  
generic for clomid
2020-07-05, 08:05:56
Rosa from Uzbekistan  
cephalexin without a vet prescription
You are on page 1 of 2, other pages: [1] 2



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: