[英]How to get the current location,mouse position and current url using javascript browser detect
我正在创建一个监视网站的工具。
为此,我需要使用javascript浏览器检测来获取当前位置,鼠标位置和当前网址
我怎样才能做到这一点?
我知道下面的代码对于获取当前位置是正确的。
var loc = navigator.geolocation.getCurrentPosition;
console.log(loc);
.
(句点)不是,
(逗号) getCurrentPosition
是一个函数 ,您需要调用它(使用()
) getCurrentPosition
可能必须发出网络请求才能确定结果,因此它是异步的。 您必须将回调函数作为第一个参数传递给它。 这样:
function showPositionData(result) {
console.log(result);
}
navigator.geolocation.getCurrentPosition(showPositionData);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.