【发布时间】:2013-07-06 14:27:46
【问题描述】:
我正在使用此代码来查找当前位置的纬度和经度。
$(document).ready(function() {
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
}
else
{
alert('It seems like Geolocation, which is required for this page, is not enabled in your browser.');
}
});
function successFunction(position)
{
var lat = position.coords.latitude;
var long = position.coords.longitude;
alert('Your latitude is :'+lat+' and longitude is '+long);
}
function errorFunction(position)
{
alert('Error!');
}
它在 Chrome 中运行良好,但在 Mozilla 中却不行。也没有警报错误消息。
【问题讨论】:
-
检查您的 Firefox 开发者控制台(如果安装了 Firebug,则为 Ctrl+Shift+I 或 F12)是否有脚本错误或其他
-
您的代码是否要求获得使用该功能的权限?
Any add-on hosted on addons.mozilla.org which makes use of geolocation data must explicitly request permission before doing so来自 mdn fopund here -
它在 Chrome 和 Mozilla 中都适用于我。
-
问题很小,你已经定义了变量名
longcheck..var long =its keyword in javascript
标签: javascript jquery html firefox mozilla