0
<html>
<body>

<script src="something"></script>

<img src="something">


<script>
window.onload = function () {

//code logic here

}
</script>
</body>
</html>


I want to access the http response headers for all the http requests of this page so that I can determine their status.

such as response header for first script request and others subsequently.

In other words I want to count the no. of requests for which the response status was an error.

Neeraj
  • 58
  • 1
  • 3
  • 9

1 Answers1

1

try this:

var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
alert(headers);
Engineer
  • 5,911
  • 4
  • 31
  • 58