landscape or portrait ?


  • I everybody ..

    How can I know if the devices is in portrait mode or landscape mode !?

    thx ! xD

    Friday, May 04, 2012 7:09 PM


  • var mql = window.msMatchMedia("(-ms-view-state: fullscreen-portrait)");
    if (mql.matches) {
      RepositionForPortrait(); // If already in portrait, move 
    mql.addListener(function (mql) {
      if (mql.matches) {
        RepositionForPortrait(); // This runs when going from landscape to portrait

    I'm guessing you mean in JavaScript, here is an example.

    The listener is the one that runs when the user switches orientation. The first match of course just runs on load.

    Friday, May 04, 2012 7:54 PM