app.base.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //判断浏览器内核、手机系统等,使用 Base.browser.ios
  2. var Base = {};
  3. Base.browser = function () {
  4. var u = navigator.userAgent;
  5. var ua = navigator.userAgent.toLocaleLowerCase();
  6. var app = navigator.appVersion;
  7. return {
  8. trident: u.indexOf('Trident') > -1, // IE内核
  9. presto: u.indexOf('Presto') > -1, // opera内核
  10. webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
  11. gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, // 火狐内核
  12. mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), // 是否为移动终端
  13. ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), // IOS终端
  14. android: u.indexOf('Android') > -1 , // 安卓终端
  15. iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, // 是否为iphone或QQHD浏览器
  16. iPad: u.indexOf('iPad') > -1, // 是否为iPad
  17. webApp: u.indexOf('Safari') == -1, // 是否web应用程序,没有头部与底部
  18. QQbrw: u.indexOf('MQQBrowser') > -1, // QQ浏览器
  19. weiXin: u.indexOf('MicroMessenger') > -1, // 微信
  20. QQ: ua.match(/QQ/i) == "qq", // QQ
  21. weiBo: ua.match(/WeiBo/i) == "weibo", // 微博
  22. safari: /Safari/.test(u) && !/Chrome/.test(u) && u.indexOf('MQQBrowser') < 0,
  23. ucLowEnd: u.indexOf('UCWEB7.') > -1, //
  24. ucSpecial: u.indexOf('rv:1.2.3.4') > -1,
  25. webview: !(u.match(/Chrome\/([\d.]+)/) || u.match(/CriOS\/([\d.]+)/)) && u.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),
  26. ucweb: function () {
  27. try {
  28. return parseFloat(u.match(/ucweb\d+\.\d+/gi).toString().match(/\d+\.\d+/).toString()) >= 8.2
  29. } catch (e) {
  30. if (u.indexOf('UC') > -1) {
  31. return true;
  32. }
  33. return false;
  34. }
  35. }(),
  36. Symbian: u.indexOf('Symbian') > -1,
  37. ucSB: u.indexOf('Firofox/1.') > -1
  38. };
  39. }();