<!DOCTYPE html>
<html>
<body>
<p id="demo">Click the button to get your coordinates:</p>
<button onclick="getLocation()">Try It</button>
<script>
var x=document.getElementById("demo")
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition)
}
else{x.innerHTML="Geolocation is not supported by this browser."}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude
}
</script>
</body>
</html>
TP有自带的IP检测函数,叫 get_client_ip(),如果要具体位置的话,也有自带的类!
$Ip = new \Org\Net\IpLocation('UTFWry.dat') // 实例化类 参数表示IP地址库文件$area = $Ip->getlocation('203.34.5.66') // 获取某个IP地址所在的位置
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)