説明なし

common.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  2. window.onresize = function(){
  3. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  4. }
  5. function parseQueryString(url) {
  6. // var urlObj = {};
  7. // var reg = /([^?=&]+)=([^?=&]+)/g;
  8. // url.replace(reg, ($0, $1, $2) => {
  9. // urlObj[$1] = decodeURIComponent($2);
  10. // })
  11. // return urlObj;
  12. var query = window.location.search.substring(1);
  13. var vars = query.split("&");
  14. for (var i=0;i<vars.length;i++) {
  15. var pair = vars[i].split("=");
  16. if(pair[0] == variable){return pair[1];}
  17. }
  18. return(false);
  19. }
  20. /**
  21. * [showMsg 提示各种错误信息,3s后消失]
  22. <div class="alert-info" style="display: none;">
  23. <p></p>
  24. </div>
  25. */
  26. function showMsg(msg) {
  27. var msgBox = $('.alert-info');
  28. msgBox.children('p').text(msg);
  29. msgBox.show();
  30. setTimeout(function() {
  31. msgBox.hide();
  32. }, 3000);
  33. }
  34. function lastHref() {
  35. // var pathName = window.location.pathname.substring(1);
  36. // var DirName = pathName == '' ? '' : pathName.substring(0, pathName.lastIndexOf('/'));
  37. // var reg=new RegExp("%20","g");
  38. // return window.location.origin+"/"+DirName.replace(reg, " ");//替换空格
  39. var test=window.location.pathname;
  40. var newTest=test.split("/")
  41. var test1=newTest[newTest.length-1];
  42. return window.location.host+test.replace("/"+test1,"")
  43. }