1. ;(function (win, UP) {
    2. "use strict";
    3. UP.W = UP.W || {};
    4. UP.W.Rem = UP.W.Rem || {};
    5. var timer = null;
    6. var rem = 12;
    7. var doc = win.document;
    8. var docEl = doc.documentElement;
    9. /**
    10. * 刷新页面REM值
    11. */
    12. function refreshRem() {
    13. var width = docEl.getBoundingClientRect().width;
    14. width = width > 768 ? 750 : width;
    15. rem = width / 7.5;
    16. docEl.style.fontSize = rem + 'px';
    17. }
    18. /**
    19. * 页面缩放或重载时刷新REM
    20. */
    21. win.addEventListener('resize', function () {
    22. clearTimeout(timer);
    23. timer = setTimeout(refreshRem, 300);
    24. }, false);
    25. win.addEventListener('pageshow', function (e) {
    26. if (e.persisted) {
    27. clearTimeout(timer);
    28. timer = setTimeout(refreshRem, 300);
    29. }
    30. }, false);
    31. // 解决font-size过大导致间距不正常,必须指定body字号为12px
    32. if (doc.readyState === 'complete') {
    33. doc.body.style.fontSize = '12px';
    34. } else {
    35. doc.addEventListener('DOMContentLoaded', function (e) {
    36. doc.body.style.fontSize = '12px';
    37. }, false);
    38. }
    39. refreshRem();
    40. /**
    41. * rem to px
    42. * @param d
    43. * @returns {number}
    44. */
    45. UP.W.Rem.rem2px = function (d) {
    46. var val = parseFloat(d) * rem;
    47. if (typeof d === 'string' && d.match(/rem$/)) {
    48. val += 'px';
    49. }
    50. return val;
    51. };
    52. /**
    53. * px to rem
    54. * @param d
    55. * @returns {number}
    56. */
    57. UP.W.Rem.px2rem = function (d) {
    58. var val = parseFloat(d) / rem;
    59. if (typeof d === 'string' && d.match(/px$/)) {
    60. val += 'rem';
    61. }
    62. return val;
    63. };
    64. })(window, window.UP || (window.UP = {}));
    1. function browserRedirect(url) {
    2. var Url = url;
    3. var sUserAgent = navigator.userAgent.toLowerCase();
    4. var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
    5. var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
    6. var bIsMidp = sUserAgent.match(/midp/i) == "midp";
    7. var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
    8. var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
    9. var bIsAndroid = sUserAgent.match(/android/i) == "android";
    10. var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
    11. var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
    12. if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
    13. // var path = location.pathname
    14. console.log(location.pathname);
    15. // var path = location.pathname.
    16. if (location.pathname == '/') {
    17. window.location.href = "/mView/index.html";
    18. } else if (location.pathname.toString().indexOf('catalog') != -1) {
    19. var _data = location.pathname.toString();
    20. _data = _data.substr(_data.lastIndexOf('/') + 1, _data.length)
    21. window.location.href = "/mView/book.html?bookId="+_data;
    22. } else if (location.pathname.toString().indexOf('class') != -1) {
    23. window.location.href = "/mView/classFirst.html"
    24. } else if (location.pathname.toString().indexOf('ranking') != -1) {
    25. window.location.href = "/mView/rank.html"
    26. } else if (location.pathname.toString().indexOf('readBook') != -1) {
    27. var _data = location.pathname.toString();
    28. _data = _data.substr(_data.lastIndexOf('/') + 1, _data.length)
    29. _data = _data.split('@');
    30. window.location.href = "/mView/read.html?bookId="+_data[1]+'&contentId='+_data[0];
    31. } else if (location.pathname.toString().indexOf('userInfo') != -1) {
    32. window.location.href = "/mView/personal.html"
    33. } else {
    34. window.location.href = "/mView/index.html";
    35. }
    36. }
    37. return false;
    38. }
    39. browserRedirect();