Javascript/PHP can I get GPS location and send it

2020-05-10 05:58发布

问题:

Ok here's what I want:

I need something like a Javascript or PHP script to get a gps location from a visitor, and then secretly send it to me (I won't use this bad, it's for an website that prevents my iPhone from being stolen)

I want that if a thief opens the website (which I will webclip, name Safari and give the safari icon) I automatically get his location and he's redirected to google or something else

So basically like this:

navigator.geolocation.getCurrentPosition(GetLocation);
function GetLocation(location) {
    //Some script that sends the location secretly to me
}
{
    windows.location="http://google.com";
}

回答1:

The ethical questions about accessing private location information without consent aside, browsers are explicitly designed not to inadvertently disclose this. This is why you'll be asked to grant access to an HTML 5 site attempting to gain access to the coordinates.

The best you could do is use a service which resolves the IP address to a physical location and makes some assumptions based on this, although the reliability of this practice is sporadic at best.