【发布时间】:2017-05-14 14:05:32
【问题描述】:
我有一个网站大部分时间都在移动设备上打开,我需要该网站默认以横向模式显示。 (虽然用户处于纵向模式,但它也应该处于横向模式)。 请帮帮我,使用哪个代码...
我使用了这段代码,但它并没有帮助我,无论如何..
<script>
var start = function() {
screen.orientation.lock('landscape-primary').then(
startInternal,
function() {
alert('To start, rotate your screen to landscape.');
var orientationChangeHandler = function() {
if (!screen.orientation.type.startsWith('landscape')) {
return;
}
screen.orientation.removeEventListener('change', orientationChangeHandler);
startInternal();
}
screen.orientation.addEventListener('change', orientationChangeHandler);
});
}
window.onload = start;
</script>
【问题讨论】:
-
您是否使用 Webview 在您的手机上显示网站??
-
我不知道怎么用,我只是用简单的HTML作为常规。
-
为什么不使用css媒体查询? jsfiddle.net/5whzxb8m
标签: javascript android html ios