var Sys = {}; var ua = navigator.userAgent.toLowerCase(); if (window.ActiveXObject) Sys.ie = ua.match(/msie ([\d.]+)/)[1] else if (document.getBoxObjectFor) Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] else if (window.MessageEvent && !document.getBoxObjectFor) Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] else if (window.opera) Sys.opera = ua.match(/opera.([\d.]+)/)[1] else if (window.openDatabase) Sys.safari = ua.match(/version\/([\d.]+)/)[1];
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
if (window.ActiveXObject)
Sys.ie = ua.match(/msie ([\d.]+)/)[1]
else if (document.getBoxObjectFor)
Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
else if (window.MessageEvent && !document.getBoxObjectFor)
Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]
else if (window.opera)
Sys.opera = ua.match(/opera.([\d.]+)/)[1]
else if (window.openDatabase)
Sys.safari = ua.match(/version\/([\d.]+)/)[1];
//以下进行测试
if(Sys.ie) document.write('IE: '+Sys.ie);
if(Sys.firefox) document.write('Firefox: '+Sys.firefox);
if(Sys.chrome) document.write('Chrome: '+Sys.chrome);
if(Sys.opera) document.write('Opera: '+Sys.opera);
if(Sys.safari) document.write('Safari: '+Sys.safari);
这个是正解..
同问2345是什么浏览器..不想下载实验您的浏览器发送的 User-Agent 信息: Mozilla/5.0 (Windows NT 6.2; Trident/7.0; rv:11.0; like Gecko; 2345Explorer 3.2.0.12012)
alert('请用2345浏览器查看本页面!')
location='跳转到你要的页面,如2345浏览器的下载地址'
}
这判断代码应该没问题,但是无法判断到2345浏览器 郁闷呢 我用2345浏览器打开它依然提示要我使用2345浏览器 (Windows NT 6.2; Trident/7.0; rv:11.0; like Gecko; 2345Explorer 3.2.0.12012)
这判断代码应该没问题,但是无法判断到2345浏览器 郁闷呢 我用2345浏览器打开它依然提示要我使用2345浏览器 (Windows NT 6.2; Trident/7.0; rv:11.0; like Gecko; 2345Explorer 3.2.0.12012) 说明你的userAgent没有包含2345Explorer,严格区分大小写的,自己输出userAgent对比下不就知道了if(navigator.userAgent.indexOf('2345Explorer')==-1){
alert('请用2345浏览器查看本页面!\nuserAgent'+navigator.userAgent.)
location='跳转到你要的页面,如2345浏览器的下载地址'
}