<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.
例如第一个脚本请求的响应头和随后的其他脚本。
换句话说,我想算不上。响应状态为错误的请求。
答案 0 :(得分:0)
试试这个:
var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
alert(headers);