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.

1
  • Have you considered just using something like Fiddler? Commented Feb 28, 2013 at 12:46

1 Answer 1

1

try this:

var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
alert(headers);
Sign up to request clarification or add additional context in comments.

4 Comments

This will only give me response header for the document not all the response headers for all the requests.
all the response headers for all the requests??
<script src="something"> also makes a request I want to know what was the response for such requests as well.
How about keeping this code in a function and calling it in places where you want to get the response?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.