我可以使用 jquery 确定设备是处于纵向还是横向模式吗? [英] Can I determine if a device is in portrait or landscape mode using jquery?

查看:22
本文介绍了我可以使用 jquery 确定设备是处于纵向还是横向模式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有条件地更改用户在我要创建的照片库网站上看到的内容,具体取决于用于查看网站的设备是处于纵向/垂直还是横向/水平模式/方向.这可能吗?

I want to conditionally alter what the user sees on the photo gallery web site I'm going to create based on if the device being used to view the site is in portrait/vertical vs. landscape/horizontal mode/orientation. Is this possible?

推荐答案

尝试 orientationchange 事件处理程序,如下所示:

Try the orientationchange event handler, something like this:

$(window).bind("orientationchange", function(evt){
    alert(evt.orientation);
});

这是关于检测和触发 orientationchange 事件的 jQuery Mobile 条目.

Here's the jQuery Mobile entry on detecting and firing the orientationchange event.

这篇关于我可以使用 jquery 确定设备是处于纵向还是横向模式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆