【问题标题】:simpleweatherjs plugin: Firefox asks me to share my location but wont display current temperature简单的天气插件:Firefox 要求我分享我的位置,但不会显示当前温度
【发布时间】:2014-08-14 03:44:53
【问题描述】:

嗨,我有一个来自simpleweatherjs 的工作天气脚本,我觉得这很奇怪,因为从我发现的示例中,一切都在差异浏览器上运行,但是当我通过结合自动更新和地理定位并在我们的同事的帮助下自定义插件时在堆栈中,我设法使其运行,但仅在 chrome 上运行,因为当我在 Firefox 上对其进行测试时,它只会在我允许它没有发生任何事情后询问我是否要共享位置

这是完整的代码

    <script type="text/javascript">

    $(document).ready(function() {
        getWeather();
        setInterval(getWeather, 6000);
    });

    function getWeather() {

        navigator.geolocation.getCurrentPosition(function(position) {

            var location = (position.coords.latitude + ',' + position.coords.longitude);
            var woeid = undefined;

            $.simpleWeather({
                location: location,
                woeid: woeid,
                unit: 'c',
                success: function(weather) {
                    html = '<h2><i class="icon-'+weather.code+'"></i>' + weather.temp + '&deg;' + weather.units.temp + '</h2>';
                    html += '<ul><li>' + weather.city + ', ' + weather.region + '</li>';
                    html += '<li class="currently">' + weather.currently + '</li></ul>';

                    $("#weather").html(html);
                },
                error: function(error) {
                    $("#weather").html('<p>' + error + '</p>');
                }
            });
        });
    }
</script>

谁能告诉我这里哪里出错了?

【问题讨论】:

    标签: javascript jquery firefox weather-api


    【解决方案1】:

    这里是 simpleWeather 的开发者。我有几个人报告了这个问题,还有几个人没有任何问题。我做了一点挖掘,对于某些人来说,Firefox 和地理位置似乎存在问题。我在stackoverflow上发现了这个post from Mozilla Supportseveral issues关于这个问题。不确定该解决方案是否能解决您的问题。

    【讨论】:

      猜你喜欢
      • 2013-02-05
      • 2019-12-17
      • 2016-07-16
      • 2021-06-02
      • 2018-08-23
      • 2017-04-03
      • 1970-01-01
      • 1970-01-01
      • 2014-09-06
      相关资源
      最近更新 更多