我有一个使用HTML5地理位置报告我的位置的应用程序.该应用程序在Firefox和Chrome上运行正常,但在Safari 5上,它表示Safari不支持Geolocation.
从我读到的,Safari 5确实支持Geolocation.我错过了什么?
谢谢你的时间.
苏尼尔
W3C地理位置API似乎在safari 5中不起作用.我尝试了这个页面,它告诉我Geolocation不成功.
代码:http: //code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html
有人可以解释一下为什么会这样吗?
致力于html5地理定位.
尝试过mozilla,chrome,IE.他们工作正常,但没有为野生动物园工作.在Mac上的safari(8.0.5)上进行测试,在windows上使用safari(5.1)进行测试
只需点击网址
http://www.w3schools.com/html/html5_geolocation.asp
Run Code Online (Sandbox Code Playgroud)
要么
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>
Run Code Online (Sandbox Code Playgroud)
它允许弹出允许/禁止但在允许后不执行任何操作.我已经在Mac上测试了与wi-fi连接的Safari,但不适用于wi-fi和LAN上的笔记本电脑.