如何在javascript / jquery中找出ipad是否处于横向/纵向模式? [英] How to find out if ipad is in landscape/portrait mode in javascript/jquery?

查看:103
本文介绍了如何在javascript / jquery中找出ipad是否处于横向/纵向模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果ipad处于横向模式,我想添加一个额外的div。
是否有某种if语句可以找到它?

I want to add an extra div if the ipad is in landscape mode. Is there some sort of if statement that could find this out?

谢谢

推荐答案

jQTouch检查如下:

jQTouch checks it like so:

orientation = Math.abs(window.orientation) == 90 ? 'landscape' : 'portrait';

http://github.com/senchalabs/jQTouch/blob/master/jqtouch/jqtouch.js

您还可以收听onorientationchange事件

You can also listen to onorientationchange events

请参阅上一个答案:使用JavaScript在浏览器中检测Android手机的旋转

这篇关于如何在javascript / jquery中找出ipad是否处于横向/纵向模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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