Jaye Tan's Octopress Blog

Just Blogs

Detect Mobile - Tablet Orientation Using Jquery

This Javascript / Jquery code can detect mobile or tablet orientation.

    window.addEventListener("orientationchange", function() {
        var orientation = window.orientation;
      }, false);

a portrait orientation will result of a value of “0” while landscape orientation will yield a result of “90” you can now use this value to create a conditional statements, this is helpful if you are creating a realtime orientation query.

tags: javascript mobile orientation, javascript tablet orientation, device orientation jquery, jquery window orientation