DelphiFAQ Home Search:

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


comments8 comments. Current rating: 4 stars (3 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);


Content-type: text/html


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  



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: