我有这个位置脚本:
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<p id="demo"> </p>
<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;
}
window.onload = getLocation();
</script>
</body>
</html>
它工作得很好,但我想做的是再一次在我的身体中显示坐标而不复制相同的脚本。例如,我只想要 php code echo $coords 之类的东西?