How to restrict browser view to Landscape on a mobile browser in HTML5?

假装没事ソ 提交于 2019-12-13 12:16:02

问题


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.


回答1:


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

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.



来源:https://stackoverflow.com/questions/8292520/how-to-restrict-browser-view-to-landscape-on-a-mobile-browser-in-html5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!