地理定位在 Windows 7/XP 上的 Safari 5.x 上不起作用

Geolocation not working on Safari 5.x on Windows 7/XP(地理定位在 Windows 7/XP 上的 Safari 5.x 上不起作用)
本文介绍了地理定位在 Windows 7/XP 上的 Safari 5.x 上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在开发一个使用 W3C 标准地理定位 API 的应用程序,但我终生无法让它在我的 Windows 7 和 XP PC 上的 Safari 上运行.它在我的 iPad 和 iPhone 上运行良好.它还可以在 Chrome(5、6、7 和 Canary 版本)和 Firefox(3.6)上完美运行.我没有Mac,所以无法对其进行测试.IE 还不支持地理定位,因此也涵盖了这一点.

I am working on an app that uses the W3C standard geolocation API but I cannot for the life of me get it to work on Safari on my Windows 7 and XP PC. It works fine on my iPad and my iPhone. It also works perfect on Chrome (5, 6, 7 and the Canary build) and on Firefox (3.6). I don't have a Mac so I can't test it on that. IE doesn't support geolocation yet so that's covered too.

我创建了一个精简版并将其托管在 Google Apps Engine 上,因此您可以查看代码:http://html5-geolocator.appspot.com/ .所有(简化的)javascript 都在 html 中,因此您应该能够右键单击并调试/查看源代码.

I created a stripped down version and I am hosting it on the Google Apps Engine so you can have a look at the code: http://html5-geolocator.appspot.com/ . All the (simplified) javascript is in the html so you should be able to right-click and debug/view source.

这几乎是 Google 上的示例的直接转换地图 API 开发指南.有趣的是,Google 托管的示例也不适用于 Windows 7 上的 Safari 5.0.x(但它们在所有其他平台上都可以正常工作,与我的应用程序相同),例如 http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html 和我的APP一模一样的问题,没有地图,网页一直是灰色的.

It is pretty much a straight conversion of the examples on the Google Map API DevGuide. Interestingly enough, the examples that Google is hosting are also NOT WORKING in Safari 5.0.x on Windows 7 (but they work fine on all those other platforms, same as my app), for example http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html exhibits exactly the same issue as my APP, no map appears, the webpage just stays grey.

通过一些调试 (alert("I am here") :-) 似乎在 Safari 中,它确实执行了 navigator.geolocation.getCurrentPosition(myCallback),但它似乎永远不会到达 myCallback ...就好像它从来没有从 getCurrentPosition 返回.我还看到,如果我让浏览器窗口在一夜之间打开,当我早上回到它时,警报和地图就会出现(尽管并非总是如此).我还尝试添加了 errorCallback navigator.geolocation.getCurrentPosition(myCallback, errorCallback) 但它也从未执行过,再次表明它永远不会从 getCurrentPosition 调用返回.

Through some debugging (alert("I am here") :-) it seems that in Safari, it does execute navigator.geolocation.getCurrentPosition(myCallback), but it never seems to reach myCallback ... as if it never returns from getCurrentPosition. I have also seen that if I leave the browser window open overnight, when I get back to it in the morning the alert and map have appeared (though not always). I also tried added a errorCallback navigator.geolocation.getCurrentPosition(myCallback, errorCallback) but it also never executes that, again suggesting it never returns from the getCurrentPosition call.

为什么会这样?

只是做了一些更多的测试,我添加了超时选项 (navigator.geolocation.getCurrentPosition(myCallback, errorCallback, {timeout: 5000});) ,事实上它一直超时,不管我设置多高所以它永远不会从 Google 地理定位服务返回,但为什么呢?

Just did some more testing, I added the timeout option (navigator.geolocation.getCurrentPosition(myCallback, errorCallback, {timeout: 5000});) , and indeed it it timing out all the time, no matter how high I set it so it is never returning from the Google geolocation service, but why?

推荐答案

尝试打开你的 wi-fi.看来 Safari 依赖于 wi-fi 连接才能工作.我遇到了完全相同的问题,打开了我的 wi-fi 连接,它运行良好.

Try turning on your wi-fi. It appears that Safari relies on the wi-fi connection to work. I was having exactly the same issues, turned my wi-fi connection on and it work perfectly.

我现在正在研究如何检测这一点 - 如果我找到解决方案会更新

I'm now looking at how to detect this - will update if I find a solution

这篇关于地理定位在 Windows 7/XP 上的 Safari 5.x 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
How can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)
How do I get the HTTP status code with jQuery?(如何使用 jQuery 获取 HTTP 状态码?)
$.ajax call working fine in IE8 and Doesn#39;t work in firefox and chrome browsers($.ajax 调用在 IE8 中运行良好,但在 Firefox 和 chrome 浏览器中不起作用)
How do I know if jQuery has an Ajax request pending?(我如何知道 jQuery 是否有待处理的 Ajax 请求?)
document.write() overwriting the document?(document.write() 覆盖文档?)