gpt4 book ai didi

Javascript 检测 IE11 版本

转载 作者:行者123 更新时间:2023-11-30 00:15:44 26 4
gpt4 key购买 nike

<分区>

我正在努力在下面的代码中正确查找客户端浏览器版本。一切正常,但 IE11 版本号。我一直得到 5 的值。浏览器正确显示我测试的所有版本,但 IE11。我已经尝试了几件事,但我很困惑。谁能帮我解决我所缺少的,谢谢。

// BrowserInformation
vm.objappVersion = navigator.appVersion;
vm.objAgent = navigator.userAgent;
vm.objbrowserName = navigator.appName;
vm.objfullVersion = ''+parseFloat(navigator.appVersion);
vm.objBrMajorVersion = parseInt(navigator.appVersion,10);
vm.objOffsetName = '';
vm.objOffsetVersion = '';
vm.ix;
// In Chrome
if ((vm.objOffsetVersion = vm.objAgent.indexOf("Chrome")) != -1) {
vm.objbrowserName = "Chrome"; vm.objfullVersion = vm.objAgent.substring(vm.objOffsetVersion + 7);
}
// In IE11
else if ((vm.objOffsetVersion = vm.objAgent.indexOf("rv")) != -1) {
vm.objbrowserName = "Microsoft Internet Explorer Version 11"; vm.objfullVersion = vm.objAgent.substring(vm.objOffsetVersion + 10);
}
// In Microsoft internet explorer all other versions
else if ((vm.objOffsetVersion = vm.objAgent.indexOf("MSIE")) != -1) {
vm.objbrowserName = "Microsoft Internet Explorer"; vm.objfullVersion = vm.objAgent.substring(vm.objOffsetVersion + 5);
}
// In Firefox
else if ((vm.objOffsetVersion = vm.objAgent.indexOf("Firefox")) != -1) {
vm.objbrowserName = "Firefox";
}
// In Safari
else if ((vm.objOffsetVersion = vm.objAgent.indexOf("Safari")) != -1) {
vm.objbrowserName = "Safari"; vm.objfullVersion = vm.objAgent.substring(vm.objOffsetVersion + 7);
if ((vm.objOffsetVersion = vm.objAgent.indexOf("Version")) != -1) vm.objfullVersion = vm.objAgent.substring(vm.objOffsetVersion + 8);
}
// For other browser "name/version" is at the end of userAgent
else if ((vm.objOffsetName = vm.objAgent.lastIndexOf(' ') + 1) < (vm.objOffsetVersion = vm.objAgent.lastIndexOf('/'))) {
vm.objbrowserName = vm.objAgent.substring(vm.objOffsetName, vm.objOffsetVersion); vm.objfullVersion = vm.objAgent.substring(vm.objOffsetVersion + 1);
if (vm.objbrowserName.toLowerCase() == vm.objbrowserName.toUpperCase()) { vm.objbrowserName = navigator.appName; }
}
// trimming the fullVersion string at semicolon/space if present
if ((vm.ix = vm.objfullVersion.indexOf(";")) != -1)
vm.objfullVersion = vm.objfullVersion.substring(0, vm.ix);
if ((vm.ix = vm.objfullVersion.indexOf(" ")) != -1)
vm.objfullVersion = vm.objfullVersion.substring(0, vm.ix);
vm.objBrMajorVersion = parseInt('' + vm.objfullVersion, 10);
if (isNaN(vm.objBrMajorVersion)) {
vm.objfullVersion = '' + parseFloat(navigator.appVersion);
vm.objBrMajorVersion = parseInt(navigator.appVersion, 10);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com