[英]Orientation is shown wrong while rotating device Google chrome
我有一个HTML5页面,该页面确定设备是“纵向”模式还是“横向”模式。
下面是我已通知方向的代码。 有时,当我从风景转向肖像时,由于风景和我检查的坐标显示为错误,它仍然会发出警报。 测试设备是Google Nexus
平板电脑Google Nexus 7 Andriod版本4.2.2 Chrome应用版本:35.0.1916.141 OS Andriod 4.4.2; Nexus 7 Build / KOT49H Javascript版本:V8 3.25.28.18
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="page">
</div>
</body>
</html>
<script type="text/javascript">
function pageSetter() {
if (window.matchMedia("(orientation: portrait)").matches) {
// you're in PORTRAIT mode
alert('Portrait');
}
if (window.matchMedia("(orientation: landscape)").matches) {
// you're in LANDSCAPE mode
alert('LANDSCAPE');
}
}
pageSetter();
window.addEventListener("orientationchange", function () {
pageSetter();
}, false)
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.