Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.86 KB | None | 0 0
  1. <meta id='viewport' name="viewport" content="width=480, height=640,initial-scale=1, maximum-scale=1, user-scalable=no" />
  2.  
  3. <script>
  4.    
  5.     //Get meta tag
  6.     var meta = document.getElementById('viewport');
  7.    
  8.     var scaleAmount = 1;
  9.     var width = window.outerWidth;
  10.     var height = window.outerHeight;
  11.    
  12.     if(window.outerWidth > window.outerHeight)
  13.     {
  14.         width = window.outerHeight;
  15.         height = window.outerWidth;
  16.     }
  17.  
  18.     var border = 1;
  19.     var windowWidth = width - (border * 2);
  20.     var windowHeight = height - (border * 2);
  21.    
  22.     var widthRatio = windowWidth / 480;
  23.     var heightRatio = windowHeight / 640;
  24.    
  25.     if(widthRatio < heightRatio)
  26.     {
  27.         scaleAmount = widthRatio;
  28.     }
  29.     else
  30.     {
  31.         scaleAmount = heightRatio;
  32.     }
  33.    
  34.     meta.setAttribute('content','width=480,height=640,initial-scale='+scaleAmount+', maximum-scale='+scaleAmount+', user-scalable=no');
  35.    
  36.    
  37.    
  38. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement