获取浏览器设备信息
function browser() {
var e = document.createElement("canvas");
if (e && "function" == typeof e.getContext)
for (var t = ["webgl", "webgl2", "experimental-webgl2", "experimental-webgl"], r = 0;
r < t.length;
r++) {
var i = t[r],
o = e.getContext(i);
if (o) {
var a = {};
a.context = i,
【获取浏览器设备信息】a.version = o.getParameter(o.VERSION),
a.vendor = o.getParameter(o.VENDOR),
a.sl_version = o.getParameter(o.SHADING_LANGUAGE_VERSION),
a.max_texture_size = o.getParameter(o.MAX_TEXTURE_SIZE);
var c = o.getExtension("WEBGL_debug_renderer_info");
return c && (a.vendor = o.getParameter(c.UNMASKED_VENDOR_WEBGL), a.renderer = o.getParameter(c.UNMASKED_RENDERER_WEBGL)), a
}
}
return {}
}
var swidth = window.screen.width || "";
//屏幕分辨率的宽度
var sheight = window.screen.height || "";
//屏幕分辨率的高度
var sp = window.devicePixelRatio || "";
//设备像素比
var version = browsers.version || getVersion();
//浏览器version
var renderer = browsers.renderer || getRenderer();
//浏览器renderer
function getRenderer() {
var canvas = document.createElement('canvas');
gl = canvas.getContext('webgl') || canvas.getContext('webgl2') || canvas.getContext('experimental-webgl2') || canvas.getContext('experimental-webgl');
if (gl === null) {
return '';
}
debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
if (debugInfo === null) {
return '';
} else {
return gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
}
}
function getVersion() {
var canvas = document.createElement('canvas');
gl = canvas.getContext('webgl') || canvas.getContext('webgl2') || canvas.getContext('experimental-webgl2') || canvas.getContext('experimental-webgl');
if (gl == null) {
return '';
}
debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
return gl.getParameter(gl.VERSION);
}
推荐阅读
- 操作系统|[译]从内部了解现代浏览器(1)
- EditText默认不获取焦点弹出键盘
- Android|Android install 多个设备时指定设备
- 分享!如何分分钟实现微信扫二维码调用外部浏览器打开指定页面的功能
- whlie循环和for循环的应用
- 【实用教程】4种获取无水印视频素材的方法
- 插件化无法获取或找到.so文件
- Python+树莓派制作IoT(物联网)门控设备
- 获取知识的门槛
- 提取ipa|提取ipa 包内资源