3

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

enter image description here

EnexoOnoma
  • 8,454
  • 18
  • 94
  • 179
  • Take a look into >document.referrer< and >navigation.userAgent<. – Xatenev Aug 19 '14 at 10:36
  • 1
    possible duplicate of [Accessing the web page's HTTP Headers in JavaScript](http://stackoverflow.com/questions/220231/accessing-the-web-pages-http-headers-in-javascript) – Marius Bancila Aug 19 '14 at 10:37

2 Answers2

0

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);
Georgi Bilyukov
  • 645
  • 4
  • 11
0
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

Shanker Paudel
  • 740
  • 1
  • 9
  • 21