<html> <body> <p id=demo>点击下面的按钮获取位置</p> <button onclick="getLocation()">获取位置</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 + "&Longitude=" + position.coords.longitude; } </script>
</body> </html>
上面的代码输出的是Latitude=116.133&Longitude=39.939 我现在想要输出 <a href=http://www.a.com/weizhi.php?Latitude=116.133&Longitude=39.939
应该怎么改代码?谢谢
|