【发布时间】:2019-09-05 01:09:23
【问题描述】:
我已经在我的计算机上的虚拟机上安装了 Fedora,当我在手机上查看该网站时,我一直在尝试触发 deviceOrientation 事件。
它一直没有工作,所以使用这个线程的答案:How to check for a device/browser that fully supports the deviceorientation event?,我运行了这段代码来检查它是否受支持:
if (window.DeviceOrientationEvent && 'ontouchstart' in window) {
// setup real compass thing, with event.alpha
document.write("haz!");
} else {
// setup some mouse following hack
document.write("nope");
}
这导致“不”。但我知道我的手机支持 deviceOrientation,因为 MDN 上的示例有效。
然后,我将完全相同文件上传到我自己的网站,你瞧,它给了我“haz!”。
我不知道为什么我使用的服务器会影响是否支持 deviceOrientation。我唯一能想到的是它可能需要 SSL,但我在任何文档中都没有看到 SSL,而且我之前在我的树莓派上托管的网站上使用了 deviceOrientation,它没有 SSL。
【问题讨论】:
标签: javascript server device-orientation