onenethelper.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. var onenetHelperInit = new Object();
  2. var oneNetHelper;
  3. onenetHelperInit.Init = function () {
  4. var IsIE = (!!window.ActiveXObject || "ActiveXObject" in window) ? true : false;
  5. if (IsIE){
  6. oneNetHelper = oneNetHelper_activex;
  7. }
  8. else {
  9. var brs = getBrowserType();
  10. if (brs == "qax" || brs == "uos") {
  11. oneNetHelper = oneNetHelper_np;
  12. }
  13. else if (brs == "chrome") {
  14. if (isLinux()) {
  15. oneNetHelper = oneNetHelper_np;
  16. }
  17. else {
  18. oneNetHelper = oneNetHelper_webext;
  19. }
  20. }
  21. else {
  22. oneNetHelper = oneNetHelper_webext;
  23. }
  24. }
  25. }
  26. /***
  27. * 获取当前浏览器类型
  28. */
  29. function getBrowserType() {
  30. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  31. var isOpera = userAgent.indexOf("Opera") > -1;
  32. if (isOpera) { //判断是否Opera浏览器
  33. return "opera";
  34. }
  35. if (userAgent.indexOf("Firefox/31") > -1) { //判断是否Firefox浏览器
  36. return "uos";
  37. }
  38. if (userAgent.indexOf("Firefox") > -1) { //判断是否Firefox浏览器
  39. return "firefox";
  40. }
  41. if (userAgent.indexOf("Chrome") > -1) {
  42. var bsrt = getShellerType();
  43. if (bsrt == "") {
  44. return "chrome";
  45. } else {
  46. return bsrt;
  47. }
  48. }
  49. if (userAgent.indexOf("Safari") > -1) { //判断是否Safari浏览器
  50. return "safari";
  51. }
  52. if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) { //判断是否IE浏览器
  53. return "ie";
  54. }
  55. return "";
  56. }
  57. function getShellerType() {
  58. var brwType = "",
  59. userAgent = window.navigator.userAgent,
  60. external = window.external;
  61. if(external && 'SEVersion' in external) { // 搜狗浏览器
  62. brwType = 'sougou';
  63. } else if(external && 'LiebaoGetVersion' in external) { // 猎豹浏览器
  64. brwType = 'liebao';
  65. } else if(/QQBrowser/.test(userAgent)) { //qq浏览器
  66. brwType = 'qq';
  67. } else if(/Maxthon/.test(userAgent)) { //遨游浏览器
  68. brwType = 'maxthon';
  69. } else if(/TaoBrowser/.test(userAgent)) { //淘宝浏览器
  70. brwType = 'taobao';
  71. } else if(/BIDUBrowser/.test(userAgent)) { //百度浏览器
  72. brwType = 'baidu';
  73. } else if(/UBrowser/.test(userAgent)) { //UC浏览器
  74. brwType = 'uc';
  75. } else if(/Qaxbrowser/.test(userAgent)) { //奇安信浏览器
  76. brwType = 'qax';
  77. } else if(/UOS/.test(userAgent)) { //uos浏览器
  78. brwType = 'uos';
  79. }
  80. return brwType;
  81. }
  82. function isLinux() {
  83. var userAgent = navigator.userAgent;
  84. if(userAgent.indexOf('Linux') > -1) {
  85. return true;
  86. }
  87. return false;
  88. }