help.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //application/vnd.chromium.remoting-viewer 可能为360特有 通过_mine判断是否是360
  2. export function isBrowser() {
  3. var agent = navigator.userAgent.toLowerCase()
  4. console.log(agent)
  5. System = function () {
  6. if (agent.indexOf('qqbrowser') > 0) {//判断是qq浏览器还是其它浏览器
  7. return "qq浏览器"
  8. }
  9. if (agent.indexOf("se 2.x") > 0) {
  10. return "搜狗浏览器"
  11. }
  12. var is360 = _mime("type", "application/vnd.chromium.remoting-viewer");
  13. if (is360) {
  14. return "360浏览器"
  15. }
  16. //检测是否是谷歌内核(可排除360及谷歌以外的浏览器)
  17. //测试mime
  18. function _mime(option, value) {
  19. var mimeTypes = navigator.mimeTypes;
  20. console.log(mimeTypes)
  21. for (var mt in mimeTypes) {
  22. if (mimeTypes[mt][option] == value) {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. }
  29. let s = System()
  30. if (s) {
  31. return s
  32. }
  33. if (agent.indexOf('firefox') > 0) {
  34. return "firefox浏览器"
  35. }
  36. if (agent.indexOf('trident') > 0) {
  37. return "IE浏览器"
  38. }
  39. if (agent.indexOf('edg') > 0) {
  40. return "IE浏览器"
  41. }
  42. if (agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0) {
  43. return 'Safari'
  44. }
  45. if (agent.indexOf("chrome") > 0) {
  46. return 'chrome'
  47. }
  48. }