Get index.html response headers

女生的网名这么多〃 提交于 2021-02-19 02:30:35

问题


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

enter image description here

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!