检测视口方向,如果方向是纵向显示警告消息,通知用户说明

10/14 06:57
阅读数 0

问题:

I am building a website specifically for mobile devices.我正在建立一个专门为移动设备设计的网站。 There is one page in particular which is best viewed in landscape mode.特别是有一页最好在横向模式下查看。

Is there a way to detect if the user visiting that page is viewing it in Portrait mode and if so, display a message informing the user that the page is best viewed in landscape mode?有没有办法检测访问该页面的用户是否在纵向模式下查看它,如果是,则显示一条消息,通知用户该页面最好在横向模式下查看? If the user is already viewing it in landscape mode then no message will appear.如果用户已经在横向模式下查看它,则不会出现任何消​​息。

So basically, I want the site to detect the viewport orientation, if orientation is Portrait , then display an alert message advising the user that this page is best viewed in Landscape mode.所以基本上,我希望网站检测视口方向,如果方向是Portrait ,然后显示一条警告消息,建议用户最好在横向模式下查看此页面。


解决方案:

参考一: https://en.stackoom.com/question/KdJA
参考二: https://stackoom.com/question/KdJA
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部