You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.8 KiB

3 years ago
  1. // 横屏
  2. var detectOrient = function() {
  3. var width = document.documentElement.clientWidth,
  4. height = document.documentElement.clientHeight,
  5. wrapper = document.getElementById("wrap"),
  6. style = "";
  7. if(width >= height) { // 竖屏
  8. style += "width:100%";
  9. style += "height:100%;";
  10. style += "-webkit-transform: rotate(0); transform: rotate(0);";
  11. style += "-webkit-transform-origin: 0 0;";
  12. style += "transform-origin: 0 0;";
  13. } else { // 横屏
  14. style += "width:" + height + "px;"; // 注意旋转后的宽高切换
  15. style += "height:" + width + "px;";
  16. style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
  17. // 注意旋转中点的处理
  18. style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  19. style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  20. }
  21. wrapper.style.cssText = style;
  22. }
  23. window.onresize = detectOrient;
  24. detectOrient();
  25. //$(document).ready(function(){
  26. var browser = {
  27. versions: function() {
  28. var u = navigator.userAgent,
  29. app = navigator.appVersion;
  30. return { //移动终端浏览器版本信息
  31. trident: u.indexOf('Trident') > -1, //IE内核
  32. presto: u.indexOf('Presto') > -1, //opera内核
  33. webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
  34. gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
  35. mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
  36. ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
  37. android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
  38. iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
  39. iPad: u.indexOf('iPad') > -1, //是否iPad
  40. webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
  41. };
  42. }(),
  43. language: (navigator.browserLanguage || navigator.language).toLowerCase()
  44. }