0
点赞
收藏
分享

微信扫一扫

检查竖屏横屏


(function() {
var init = function() {
var updateOrientation = function() {
var orientation = window.orientation;
switch (orientation) {
case 90:
case -90:
orientation = 'landscape'; //这里是横屏
break;
default:
orientation = 'portrait'; //这里是竖屏
break;
}
//html根据不同的旋转状态,加上不同的class,横屏加上landscape,竖屏
//加上portrait
alert(orientation);
};
// 每次旋转,调用这个事件。
window.addEventListener('orientationchange', updateOrientation, false);
// 事件的初始化
updateOrientation();
};
window.addEventListener('DOMContentLoaded', init, false);
})();


举报

相关推荐

0 条评论