How do I get these information? I am making a javascript (no jquery) that gets the plugins and user agent, and i want to include these also. I prefer client-side, I know how to do it with PHP.
I have seen it at http://browserspy.dk/headers.php and http://browserspy.dk/accept.php and https://panopticlick.eff.org/index.php?action=log&js=yes
Use this to get all the http headers:
var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
console.log(headers);
var readHeader = (function() {
// Hidden cache for the headers...
var _request = undefined;
return function(name) {
//
// We have a request cached...
///
if (_request) {
return _request.getResponseHeader(name);
}
//
// We need to get the request...
//
else {
// Do the request and wait for it to complete.
_request = new XMLHttpRequest();
_request.open("HEAD", window.location, true);
_request.send(null)
while (_request.readyState != 4) {};
return _request.getResponseHeader(name);
}
}
})();
You can try this code by thsutton documented on the below link. https://gist.github.com/thsutton/665306
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.