2

My mobile design is different from desktop, so I need to change some structure for ipad portrait. Now with my code written below it effects both on portrait and landscape. I need a script which will do some actions only for ipad portrait and even when I change orientation in this case also code work only for portrait.

Here is my code:

function orient() {  
        if (window.orientation == 0 || window.orientation == 180) {
            // some actions
        }else if (window.orientation == 90 || window.orientation == -90) {
            // some actions
        }
    }

    $(function(){
        orient();
    });

    $(window).bind( 'orientationchange', function(e){
        orient();
    });
aiddev
  • 1,409
  • 2
  • 24
  • 56
  • Use `matchMedia`, take a look at this => [matchMedia](http://stackoverflow.com/questions/4917664/detect-viewport-orientation-if-orientation-is-portrait-display-alert-message-ad) – lshettyl Sep 18 '15 at 11:53
  • So the actual question is how to detect the orientation? – m02ph3u5 Sep 18 '15 at 11:55
  • via above code I can detect, but when I change orientation it does same thing for landscape on IPAD @m02ph3u5 – aiddev Sep 18 '15 at 12:05

0 Answers0