简体   繁体   中英

Get index.html response headers

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?

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());
    }
});

You can try: window.navigator.userLanguage || window.navigator.language 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM