在移动应用中,判断屏幕竖向或横向
2011-11-26 11:12
246 查看
在移动应用中,有时要判断用户把设备竖向变成横向时,页面必须做出必须的调整,在
apple系列的机器上,如ipad,iphone,itouch等,有一个属性可以判断:
而在其他类型的移动设备上,则可能要花点心思了,要通过其长,宽的改变去判断了,用jquery其实也可以实现的,比如:
apple系列的机器上,如ipad,iphone,itouch等,有一个属性可以判断:
window.onorientationchange = detectOrientation; function detectOrientation(){ if(typeof window.onorientationchange != 'undefined'){ if ( orientation == 0 ) { //Do Something In Portrait Mode } else if ( orientation == 90 ) { //Do Something In Landscape Mode } else if ( orientation == -90 ) { //Do Something In Landscape Mode } else if ( orientation == 180 ) { //Do Something In Landscape Mode } } }
而在其他类型的移动设备上,则可能要花点心思了,要通过其长,宽的改变去判断了,用jquery其实也可以实现的,比如:
$(document).ready(function(){ if ( window.orientation != undefined ) window.onorientationchange = updateView; else $(window).resize( updateView ); } function updateView() { //在这里编写字体,样式,颜色等的改变 }
相关文章推荐
- 在移动应用中判断横向和竖向方向的改变
- 移动应用滑动屏幕方向判断解决方案
- 移动应用滑动屏幕方向判断解决方案,JS判断手势方向
- 移动应用滑动屏幕方向判断解决方案
- 移动应用滑动屏幕方向判断解决方案,JS判断手势方向
- WebApp最佳实践用户体验篇之如何针对多种屏幕尺寸设计合理的移动应用
- Android Activity应用之 横向屏幕切换
- Android实现屏幕横向 竖向的切换
- Qt移动应用开发(一):适配不同的屏幕
- 将视频移动到iPad屏幕下方为其他应用腾出位置
- windows8系统屏幕分辨率及横向/竖向屏幕显示模式设置图解
- 移动应用软件商店横向点评
- 怎么判断手指在屏幕上面水平移动超过100px
- Android首席设计师宣称移动概念已死,开发者应该面向屏幕编写应用而非移动
- ios开发中如何判断手指在屏幕上是移动事件还是点击事件
- Android首席设计师宣称移动概念已死,开发人员应该面向屏幕编写应用而非移动
- 向量叉积应用-判断鼠标移动方向
- 移动Web前端开发_横向UL以及自适应屏幕_div定位的方式居中
- 移动应用中html的head配置让界面适应屏幕
- 如何用JavaScript判断前端应用运行环境(移动平台还是桌面环境)