【发布时间】:2015-06-11 15:51:57
【问题描述】:
我编写了一些代码,提醒用户在手机上更改为横向基本上转到纵向。这很好用,但如果用户从横向开始,它显然不会显示,因为没有方向变化。有没有办法获得 get go 的方向?
$(window).on("orientationchange",function(){
if( (window.orientation == 90 && $( window ).width() < 780) || (window.orientation == -90 && $( window ).width() < 780) ) // Landscape
{
$('body').append('<div class="phoneLandscape"><h4>Sorry, this site is best viewed in Portrait Mode</h4></div>');
}
else // Portrait
{
$('.phoneLandscape').remove();
}
});
【问题讨论】:
标签: jquery