var browser = {
/*
* 获得当前浏览器的版本信息
*/
versions: function () {
var u = window.navigator.userAgent, app = window.navigator.appVersion;
return {
//IE内核
trident: u.indexOf('Trident') > -1,
//opera内核
presto: u.indexOf('Presto') > -1,
//苹果、谷歌WebKits内核
webKit: u.indexOf('AppleWebKit') > -1,
//火狐内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,
//是否为移动终端
mobile: !!u.match(/AppleWebKit.*Mobile.*/),
//ios终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
//android终端
android: u.indexOf('Android') > -1,
//iPhone
iPhone: u.indexOf('iPhone') > -1,
//iPod
iPod: u.indexOf('iPod') > -1,
//iPad
iPad: u.indexOf('iPad') > -1,
//是否web应该程序,没有头部与底部
webApp: u.indexOf('Safari') == -1
};
}()
}
document.writeln(" 是否为移动终端: "+browser.versions.mobile+"<br/>");
document.writeln(" ios终端: "+browser.versions.ios+"<br/>");
document.writeln(" android终端: "+browser.versions.android+"<br/>");
document.writeln(" 是否为iPhone: "+browser.versions.iPhone+"<br/>");
document.writeln(" 是否iPad: "+browser.versions.iPad+"<br/>");
document.writeln(navigator.userAgent+"<br/>");
document.writeln(navigator.appVersion+"<br/>");
document.writeln(navigator.appCodeName+" "+navigator.appVersion+"<br/>");
document.writeln("1---"+window.navigator.userAgent+"<br/>");
document.writeln("1---"+window.navigator.appVersion+"<br/>");
document.writeln("2---"+browser.versions.u+"<br/>");
document.writeln("2---"+browser.versions.app+"<br/>");
</script>
详细请见:
http://www.xker.com/page/e2014/0325/131654.html