screen.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function util() {
  2. this.flag = true;
  3. var body = document.body;
  4. var safe = this;
  5. var validVersion = function() {
  6. var browser = navigator.appName
  7. var b_version = navigator.appVersion
  8. var version = b_version.split(";");
  9. var trim_Version = version[1].replace(/[ ]/g, "");
  10. if (trim_Version == 'WOW64') {
  11. safe.flag = false
  12. } else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE6.0") {
  13. safe.flag = false
  14. } else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE7.0") {
  15. safe.flag = false
  16. } else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE8.0") {
  17. safe.flag = false
  18. } else if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE9.0") {
  19. safe.flag = false
  20. }
  21. }
  22. this.setBody = function() {
  23. var str = '<div class="el-tip el-tip--warning" id="tip">' +
  24. '<div class="el-tip_content">' +
  25. '<span class="el-tip__title">' +
  26. '您乘坐的浏览器版本太低了,你可以把浏览器从兼容模式调到极速模式' +
  27. '<br /> 实在不行就换浏览器吧;' +
  28. '</span>' +
  29. '<div class="el-tip_img">' +
  30. '<img src="/util/screen/huohu.png" alt="">' +
  31. '<img src="/util/screen/guge.png" alt="">' +
  32. '</div>' +
  33. '</div>' +
  34. '</div>';
  35. body.innerHTML = str + body.innerHTML
  36. }
  37. this.init = function() {
  38. validVersion(); //检测浏览器的版本
  39. return this;
  40. }
  41. }
  42. var creen = new util().init();
  43. var flag = creen.flag;
  44. if (!flag) {
  45. creen.setBody();
  46. }