Copy Code code as follows:
var $horizontal = $ ('. Horizontal_screen '); Customizable horizontal screen mode hint style
var $document = $ (document);
var preventdefault = function (e) {
E.preventdefault ();
};
var Touchstart = function (e) {
$document. On (' Touchstart touchmove ', preventdefault);
};
var touchend = function (e) {
$document. Off (' Touchstart touchmove ', preventdefault);
};
function Listener (type) {
if (' add ' = = Type) {
Vertical Screen mode
$horizontal. addclass (' hide ');
$document. Off (' Touchstart ', touchstart);
$document. Off (' Touchend ', touchend);
}else{
Horizontal screen mode
$horizontal. Removeclass (' hide ');
$document. On (' Touchstart ', touchstart);
$document. On (' Touchend ', touchend);
}
}
function Orientationchange () {
Switch (window.orientation) {
Vertical Screen mode
Case 0:
Case 180:
Listener (' add ');
Break
Horizontal screen mode
CASE-90:
Case 90:
Listener (' remove ');
Break
}
}
$ (window). On ("Onorientationchange" in Window?) "Orientationchange": "Resize", orientationchange);
$document. Ready (function () {
Enter the interface in horizontal mode, prompting to support only the vertical screen
if (window.orientation = = | | window.orientation = = 90) {
Listener (' remove ');
}
});