I'm creating a tool to monitor a website.
For that I need to get the current location, mouse position, and current url using javascript browser detection
How can I do this?
I know that the code below is correct for getting the current position.
var loc = navigator.geolocation.getCurrentPosition;
console.log(loc);
.
(period) not a ,
(comma) getCurrentPosition
is a function , you need to call it (with ()
) getCurrentPosition
may have to make network requests in order to figure out the result, so it is asynchronous. You have to pass it a callback function as its first argument. Such:
function showPositionData(result) {
console.log(result);
}
navigator.geolocation.getCurrentPosition(showPositionData);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.