如何在HTML5中将浏览器视图限制为移动浏览器上的横向? [英] How to restrict browser view to Landscape on a mobile browser in HTML5?

查看:292
本文介绍了如何在HTML5中将浏览器视图限制为移动浏览器上的横向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在HTML5中将浏览器视图限制为移动浏览器上的横向显示?在potrait视图中,它应显示切换到横向模式并在转为横向模式时加载。

How to restrict browser view to Landscape on a mobile browser in HTML5? On potrait view, it should display "Switch to landscape mode" and load when it is turned to landscape mode.

推荐答案

你可以使用浏览器的onorientationchange事件。我从我的一个测试项目中提取了一个工作示例: http://jsfiddle.net/r9b8D/

you can use the "onorientationchange" event of your browser. I extracted a working example from one of my testing projects: http://jsfiddle.net/r9b8D/

它不是你想要的,但它显示了onorientationchange的实现。将jsfiddle示例复制到您的主机并使用您的手机导航到该网站,看看会发生什么 - 也许您可以使用手机导航到jsfiddle,我不确定。

Its not exactly what you are looking for, but it shows the implementation of "onorientationchange". Copy the jsfiddle example to your host and navigate to the site with your mobile phone to see what happens - Maybe you can navigate to jsfiddle with your phone, i am not sure.

随意修改示例以满足您的需求。

Feel free to modify the example to fit your needs.

这篇关于如何在HTML5中将浏览器视图限制为移动浏览器上的横向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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