media.js 592 B

1234567891011121314
  1. new function (){
  2. var _self = this;
  3. _self.width = 640;//设置默认最大宽度
  4. _self.fontSize = 100;//默认字体大小
  5. _self.widthProportion = function(){var p = (document.body&&document.body.clientWidth||document.getElementsByTagName("html")[0].offsetWidth)/_self.width;return p<0.5?0.5:p;};
  6. _self.changePage = function(){
  7. document.getElementsByTagName("html")[0].setAttribute("style","font-size:"+_self.widthProportion()*_self.fontSize+"px !important");
  8. }
  9. _self.changePage();
  10. window.addEventListener("resize",function(){_self.changePage();},false);
  11. };