Mobile browser generally support window.orientation This parameter, through this parameter can determine whether the phone is in a horizontal screen or vertical screen state. The corresponding procedure is executed according to the actual demand. By adding the Listener event Onorientationchange, the execution will be done.
// determine the phone's status: function Hengshuping () {if (window.orientation==180| | window.orientation==0) {alert ("Vertical screen status! ")} if (window.orientation==90| | window.orientation==-90) {alert ("Horizontal screen state! ")}} window.addeventlistener (" Onorientationchange "in Window?" Orientationchange ":" Resize ", hengshuping, false);
if // ///////The user changes the screen orientation when calling $ (window). Bind (' Orientationchange ', Function (e) {orient ();});
In the development of ipad and iphone, we will probably need to determine whether it is a horizontal screen or a vertical screen. Here's how to use JQuery to determine whether an ipad, IPhone, Android is a horizontal or vertical screen
screen orientation corresponding to the Window.orientation value: ipad:90 or 90 horizontal screen ipad:0 or 180 vertical screen andriod:0 or 180 horizontal screen andriod:90 or 90 vertical screen
JS Judge Mobile Browser is a horizontal screen or vertical screen