获取index.html响应标头

时间:2015-03-31 13:07:57

标签: javascript response response-headers

注意:原来这是重复的:Accessing the web page's HTTP Headers in JavaScript

有没有办法获取index.html请求的请求标头?例如,这是我点击google.com

的屏幕截图

enter image description here

我希望能够访问请求标头。这可能吗?

其他javascript / css资产怎么样?

2 个答案:

答案 0 :(得分:-1)

这取决于您如何请求该页面,如果您使用javascript / jquery将其加载到ajax上,则可以:

$.ajax({
    type: 'GET',
    url:'google.com',
    success: function(resp){
        console.log(resp.getAllResponseHeaders());
    }
});

答案 1 :(得分:-1)

您可以尝试:window.navigator.userLanguage || window.navigator.language
或者你也可以进行ajax查询。

为此提供服务。
例如:http://ajaxhttpheaders1.appspot.com/?callback=function() {}(JSONP)