var Sys = {};
var ua = navigator.userAgent.toLowerCase();var s;(s = ua.match(/msie \d+.\d+/)) ? Sys.ie = s: (s = ua.match(/firefox\/\d+.\d+/)) ? Sys.firefox = s: (s = ua.match(/chrome\/\d+.\d+/)) ? Sys.chrome = s: (s = ua.match(/version\/\d+.\d+.\d+ safari\//)) ? Sys.safari = s : (s = ua.match(/version\/\d+.\d+/)) ? Sys.opera = s: 0;//以下进行测试
alert( navigator.userAgent );Sys.ie ? document.write('IE: ' + Sys.ie) : Sys.firefox ? document.write('Firefox: ' + Sys.firefox) : Sys.chrome ? document.write('Chrome: ' + Sys.chrome) : Sys.opera ? document.write('Opera: ' + Sys.opera) : Sys.safari ? document.write('Safari: ' + Sys.safari) : document.write(null);