【问题标题】:Compass not working on my mobile devices in Chrome 39指南针无法在 Chrome 39 中的移动设备上运行
【发布时间】:2014-11-19 21:59:54
【问题描述】:

我见过很多 HTML5 指南针示例,但没有一个适用于我的 Sony Xperia M 手机和联想 S5000 平板电脑。指南针在两个设备上的应用程序中都能正常工作。

如何让指南针在 Google Chrome 39 中工作?

示例: http://jamesgpearce.github.io/compios5/ http://www.html5rocks.com/en/tutorials/device/orientation/deviceorientationsample.html http://mobiforge.com/design-development/html5-mobile-web-device-orientation-events http://richtr.github.io/Marine-Compass/

它们都不适合我。

【问题讨论】:

    标签: html google-chrome device-orientation


    【解决方案1】:

    检查设备是否支持事件使用

    if (window.DeviceOrientationEvent) {
       alert("DeviceOrientation is supported");
    }
    

    或类似的。 Modernizr 似乎不支持对此进行特征检测。

    【讨论】:

    • 支持设备方向。
    • 然后使用 javascript 将值发送到警报或 html - 这样您就可以查看值是否正在传播到浏览器。否则可能是一个错误...尝试验证您所有的 html、javascript 和 css
    • 所有示例页面都不适合我。我不是在创建自己的指南针,只是在尝试可用的演示页面。没有演示在我的设备上运行。
    • 可以更新安卓版本吗?你在 KitKit / Lollipop 吗?如果它不能在浏览器中工作,那么要么数据没有暴露给这些设备上的浏览器,要么它们不是标准的。
    • 手机是4.3版本,平板是4.4.2。我无法升级。
    猜你喜欢
    • 2016-09-06
    • 1970-01-01
    • 2014-08-30
    • 2017-01-28
    • 2016-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-19
    相关资源
    最近更新 更多