DelphiFAQ Home Search:
General :: Programming :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

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

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:
 http.open('HEAD', location.href, false);
 http.send();
 alert(http.getAllResponseHeaders())
 
 // or display headers of yahoo.com:
 http.open('HEAD', 'http://www.yahoo.com/', false);
 http.send();
 alert(http.getAllResponseHeaders())
 
 //-->
 </script>
 

Generated 4:02:00 on Mar 26, 2017