How to lock the orientation to portrait mode in a iPhone/Andorid Web Application?

Share:
You can specify CSS styles based on viewport orientation: Target the browser with body[orient="landscape"] 
or
body[orient="portrait"]

Try this via the CSS @viewport rule

 @viewport {  
   orientation: portrait;  
 }  

Or

 $(document).ready(function () {  
    $(window)    
      .bind('orientationchange', function(){  
         if (window.orientation % 180 == 0){  
           $(document.body).css("-webkit-transform-origin", "")  
             .css("-webkit-transform", "");          
         }   
         else {            
           if ( window.orientation > 0) { //clockwise  
            $(document.body).css("-webkit-transform-origin", "200px 190px")  
             .css("-webkit-transform", "rotate(-90deg)");   
           }  
           else {  
            $(document.body).css("-webkit-transform-origin", "280px 190px")  
             .css("-webkit-transform", "rotate(90deg)");   
           }  
         }  
       })  
      .trigger('orientationchange');   
 });  

No comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();

Ads