我正在做一个网站,在那里我添加了一个按钮,标记为“我知道关于你”,当用户点击该按钮,就在它下面的所有用户信息,如他的IP地址,操作系统名称,浏览器名称和版本,请求方法get/post,&更像这个网站,它显示了大部分用户信息
我使用Stackoverflow所做的就是-
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
console.log(OSName)
暂时我想把信息记录下来,以后我会根据我的需要进行转换,但是到现在我能做什么来收集和显示像这个网站这样的用户的信息
null
var i = "";
screen.width && ((width = screen.width ? screen.width : ""), (height = screen.height ? screen.height : ""), (i += width + " x " + height));
var n,
t,
a,
o = navigator.appVersion,
r = navigator.userAgent,
d = navigator.appName,
s = "" + parseFloat(navigator.appVersion),
c = parseInt(navigator.appVersion, 10);
-1 != (t = r.indexOf("Opera")) && ((d = "Opera"), (s = r.substring(t + 6)), -1 != (t = r.indexOf("Version")) && (s = r.substring(t + 8))),
-1 != (t = r.indexOf("OPR"))
? ((d = "Opera"), (s = r.substring(t + 4)))
: -1 != (t = r.indexOf("Edge"))
? ((d = "Microsoft Legacy Edge"), (s = r.substring(t + 5)))
: -1 != (t = r.indexOf("Edg"))
? ((d = "Microsoft Edge"), (s = r.substring(t + 4)))
: -1 != (t = r.indexOf("MSIE"))
? ((d = "Microsoft Internet Explorer"), (s = r.substring(t + 5)))
: -1 != (t = r.indexOf("Chrome"))
? ((d = "Chrome"), (s = r.substring(t + 7)))
: -1 != (t = r.indexOf("Safari"))
? ((d = "Safari"), (s = r.substring(t + 7)), -1 != (t = r.indexOf("Version")) && (s = r.substring(t + 8)))
: -1 != (t = r.indexOf("Firefox"))
? ((d = "Firefox"), (s = r.substring(t + 8)))
: -1 != r.indexOf("Trident/")
? ((d = "Microsoft Internet Explorer"), (s = r.substring(r.indexOf("rv:") + 3)))
: (n = r.lastIndexOf(" ") + 1) < (t = r.lastIndexOf("/")) && ((d = r.substring(n, t)), (s = r.substring(t + 1)), d.toLowerCase() == d.toUpperCase() && (d = navigator.appName)),
-1 != (a = s.indexOf(";")) && (s = s.substring(0, a)),
-1 != (a = s.indexOf(" ")) && (s = s.substring(0, a)),
-1 != (a = s.indexOf(")")) && (s = s.substring(0, a)),
(c = parseInt("" + s, 10)),
isNaN(c) && ((s = "" + parseFloat(navigator.appVersion)), (c = parseInt(navigator.appVersion, 10)));
var v = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(o),
l = !!navigator.cookieEnabled;
void 0 !== navigator.cookieEnabled || l || ((document.cookie = "testcookie"), (l = -1 != document.cookie.indexOf("testcookie")));
var g = "-",
w = [
{ s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0)/ },
{ s: "Windows 8.1", r: /(Windows 8.1|Windows NT 6.3)/ },
{ s: "Windows 8", r: /(Windows 8|Windows NT 6.2)/ },
{ s: "Windows 7", r: /(Windows 7|Windows NT 6.1)/ },
{ s: "Windows Vista", r: /Windows NT 6.0/ },
{ s: "Windows Server 2003", r: /Windows NT 5.2/ },
{ s: "Windows XP", r: /(Windows NT 5.1|Windows XP)/ },
{ s: "Windows 2000", r: /(Windows NT 5.0|Windows 2000)/ },
{ s: "Windows ME", r: /(Win 9x 4.90|Windows ME)/ },
{ s: "Windows 98", r: /(Windows 98|Win98)/ },
{ s: "Windows 95", r: /(Windows 95|Win95|Windows_95)/ },
{ s: "Windows NT 4.0", r: /(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/ },
{ s: "Windows CE", r: /Windows CE/ },
{ s: "Windows 3.11", r: /Win16/ },
{ s: "Android", r: /Android/ },
{ s: "Open BSD", r: /OpenBSD/ },
{ s: "Sun OS", r: /SunOS/ },
{ s: "Chrome OS", r: /CrOS/ },
{ s: "Linux", r: /(Linux|X11(?!.*CrOS))/ },
{ s: "iOS", r: /(iPhone|iPad|iPod)/ },
{ s: "Mac OS X", r: /Mac OS X/ },
{ s: "Mac OS", r: /(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ },
{ s: "QNX", r: /QNX/ },
{ s: "UNIX", r: /UNIX/ },
{ s: "BeOS", r: /BeOS/ },
{ s: "OS/2", r: /OS\/2/ },
{ s: "Search Bot", r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ },
];
for (var u in w) {
var W = w[u];
if (W.r.test(r)) {
g = W.s;
break;
}
}
var O = "-";
switch ((/Windows/.test(g) && ((O = /Windows (.*)/.exec(g)[1]), (g = "Windows")), g)) {
case "Mac OS":
case "Mac OS X":
case "Android":
O = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\.\_\d]+)/.exec(r)[1];
break;
case "iOS":
O = (O = /OS (\d+)_(\d+)_?(\d+)?/.exec(o))[1] + "." + O[2] + "." + (0 | O[3]);
}
var p = "no check";
if ("undefined" != typeof swfobject) {
var x = swfobject.getFlashPlayerVersion();
p = x.major > 0 ? x.major + "." + x.minor + " r" + x.release : "-";
}
let f = {
screen: i,
browser: d,
browserVersion: s,
browserMajorVersion: c,
mobile: v,
os: g,
osVersion: O,
cookies: l,
flashVersion: p,
latitude: void 0,
longitude: void 0,
device_eventData: {
gamma: void 0,
beta: void 0,
alpha: void 0,
acceleration_x: void 0,
acceleration_y: void 0,
acceleration_z: void 0,
accelerationIncludingGravity_x: void 0,
accelerationIncludingGravity_y: void 0,
accelerationIncludingGravity_z: void 0,
accelerationIncludingGravity_z: void 0,
rotationRate_alpha: void 0,
rotationRate_beta: void 0,
rotationRate_gamma: void 0,
devicelight: void 0,
lightlevel: void 0,
deviceproximity: void 0,
userproximity: void 0,
},
batteryLevel: void 0,
};
navigator.geolocation &&
navigator.geolocation.getCurrentPosition(function (e) {
(f.latitude = e.coords.latitude), (f.longitude = e.coords.longitude);
}),
Window &&
null != window.DeviceOrientationEvent &&
window.addEventListener(
"deviceorientation",
function (e) {
(f.device_eventData.gamma = e.gamma), (f.device_eventData.beta = e.beta), (f.device_eventData.alpha = e.alpha);
},
!1
),
window &&
null != window.DeviceMotionEvent &&
window.addEventListener(
"devicemotion",
function (e) {
(f.device_eventData.acceleration_x = e.acceleration.x),
(f.device_eventData.acceleration_y = e.acceleration.y),
(f.device_eventData.acceleration_z = e.acceleration.z),
(f.device_eventData.accelerationIncludingGravity_x = e.accelerationIncludingGravity.x),
(f.device_eventData.accelerationIncludingGravity_y = e.accelerationIncludingGravity.y),
(f.device_eventData.accelerationIncludingGravity_z = e.accelerationIncludingGravity.z),
(f.device_eventData.rotationRate_alpha = e.rotationRate.alpha),
(f.device_eventData.rotationRate_beta = e.rotationRate.beta),
(f.device_eventData.rotationRate_gamma = e.rotationRate.gamma);
},
!1
),
window &&
"ondevicelight" in window &&
window.addEventListener("devicelight", function (e) {
f.device_eventData.devicelight = e.value + " lux";
}),
window &&
"onlightlevel" in window &&
window.addEventListener("lightlevel", function (e) {
f.device_eventData.lightlevel = e.value;
}),
window &&
"ondeviceproximity" in window &&
window.addEventListener("deviceproximity", function (e) {
f.device_eventData.deviceproximity = e.value + " centimeters";
}),
window &&
"ondeviceproximity" in window &&
window.addEventListener("userproximity", function (e) {
1 == e.near ? (f.device_eventData.userproximity = "Near") : (f.device_eventData.userproximity = "far");
});
var m = navigator.battery || navigator.webkitBattery || navigator.mozBattery;
function _(e) {
f.batteryLevel = parseInt(100 * e.level).toString();
}
navigator.getBattery ? navigator.getBattery().then(_) : m && _(m)
console.log("INFORMATION: ",f)
我需要一种方法来比较JavaScript中可用的所有对象信息。我尝试复制window.navigator或只使用copy(window)复制window;在chrome控制台。但是由于某些原因,当我要复制对象或将其转换为json时,总是会出现错误。我一直在查,但我真的找不到方法。我需要的是一个函数,它可以给我一个所有javascript变量的列表,这些变量是全局可用的,就像这个站点所做的一样,Br
我是新加入这个董事会的,但我已经读过你很多年了。:) 我正试着学编码,但我还在第一步。然而,我将使用一个脚本来检测用户的浏览器。 这适用于所有主要的浏览器(我在chrome、firefox和IE上试用过),但它不适用Edge。我该怎么修好它?谢谢!
问题内容: 我想检测进入我网站的浏览器的语言(如果是En或Fr)。因此,我可以重定向到En页面或其他页面。 另外,我可以检测移动语言吗? 问题答案: 尝试使用此脚本获取您的浏览器语言
通过该接口可以获取指定用户的账户信息,地址为: http://spark.bokecc.com/api/user 需要传递以下参数: 参数 说明 userid 用户id,不可为空 format 返回格式,xml 或json 返回数据user包含如下字段: 字段名 说明 account 用户账户 version 版本信息 expired 到期时间 space 用户空间信息 traffic 用户流量信
本文向大家介绍javascript 获取浏览器版本,包括了javascript 获取浏览器版本的使用技巧和注意事项,需要的朋友参考一下 工作中需要通过JS去获取当前使用的浏览器的名字以及版本号,网上大堆资料都有一个关键词是 navigator.appName,但是这个方法获取的浏览器的名字只有两种要么是IE要么就是Netscap,倒是可以用来判断是否使用了IE,但是我想获取具体的浏览器产品名字比如