2013-02-28 111 views
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. 

如第一個腳本請求的響應標頭及其他隨後的其他響應標頭。如何訪問http響應標頭

換句話說,我想指出沒有。的響應狀態是錯誤的請求。

+0

你有沒有考慮只是使用類似提琴手? – 2013-02-28 12:46:27

回答

0

試試這個:

var req = new XMLHttpRequest(); 
req.open('GET', document.location, false); 
req.send(null); 
var headers = req.getAllResponseHeaders().toLowerCase(); 
alert(headers); 
+0

這隻會爲我提供文檔的響應標題,而不是所有請求的響應標題。 – Neeraj 2013-02-28 12:57:03

+0

所有請求的所有響應標頭? – 2013-02-28 12:58:07

+1