正在處理html5地理位置。html5地理位置無法在Safari瀏覽器上工作
在Mozilla,Chrome,IE上試過。在他們身上工作得很好,但不適合徒步旅行。在Mac上的Safari(8.0.5)進行測試,Safari瀏覽器(5.1)在Windows
只是擊中網址
http://www.w3schools.com/html/html5_geolocation.asp
OR
http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<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;
}
</script>
</body>
</html>
它給彈出允許/禁止,但不執行任何操作後允許它。 我已經測試過與wi-fi連接的Mac上的Safari瀏覽器,但也不適用於wi-fi和LAN上的筆記本電腦。
如果可能的話,您可以考慮通過使用您正在測試的機器嘗試通過另一個網絡上的無線網絡進行故障排除嗎?例如,如果可以的話,從公共WiFi熱點嘗試。 – sideshowbarker
不幸的是,當Safari做到這一點時,似乎可能沒有任何有用的方式來以編程方式獲取有關失敗原因的信息(例如,如果由於機器正在使用以太網連接而導致失敗,該細節未公開由Safari以任何方式你可以到達)。但在這種情況下,您應該嘗試其他使用Geolocation API的Web應用程序(例如Web上的教程網站上的演示應用程序),並查看它們是否也在您的環境中的Safari中失效(它們幾乎肯定會)。在這種情況下,您無法解決問題。 – sideshowbarker
@sideshowbarker感謝您的建議:),我已經測試過與Wi-Fi連接的Mac上的safari,它在那裏工作,但不適用於Wi-Fi和LAN上的筆記本電腦。 – Kamini