问题
Note: Turns out this is a duplicate: Accessing the web page's HTTP Headers in JavaScript
Is there a way to get the request headers for the index.html request? For example, this is a screenshot of me hitting google.com
I would like to be able to get access to the Request Headers. Is this possible?
What about for other javascript/css assets?
回答1:
You can try: window.navigator.userLanguage || window.navigator.language
Or also you can make ajax query.
There are services for this.
Ex: http://ajaxhttpheaders1.appspot.com/?callback=function(){} (JSONP)
回答2:
It depends on how are you requesting that page, if you are loading it over ajax with javascript/jquery it is possible:
$.ajax({
type: 'GET',
url:'google.com',
success: function(resp){
console.log(resp.getAllResponseHeaders());
}
});
来源:https://stackoverflow.com/questions/29369449/get-index-html-response-headers