繁体   English   中英

如何使用Javascript从客户端获取这些信息?

[英]How to get these information from the client with Javascript?

我如何获得这些信息? 我正在制作一个获取插件和用户代理的javascript(没有jquery),我也希望包含这些。 我更喜欢客户端,我知道如何使用PHP。

我在http://browserspy.dk/headers.phphttp://browserspy.dk/accept.phphttps://panopticlick.eff.org/index.php?action=log&js=yes上看过

在此输入图像描述

使用它来获取所有http标头:

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

您可以通过以下链接中记录的thsutton尝试此代码。 https://gist.github.com/thsutton/665306

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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