简体   繁体   English

JavaScript上的“ iPad上的Safari”和“ iPhone上的Safari”之间可能存在差异

[英]Possible difference between “Safari on iPad” and “Safari on iPhone” on JavaScript

I have a project involving Google Maps API and some JavaScript codes. 我有一个涉及Google Maps API和一些JavaScript代码的项目。 The page is build upon jQuery Mobile. 该页面基于jQuery Mobile构建。 I have the web page tested on Chrome, FireFox, Opera and IE on desktop, and on various mobile phones as well. 我已经在台式机以及各种手机上的Chrome,FireFox,Opera和IE上测试了该网页。

It doesn't work only on iPhone (4, nor 5). 它仅在iPhone(4或5)上不起作用。 I mean, it's all good under Android, WP8, Chrome iPhone simulator, and even working perfectly on an iPad (Air, if matters). 我的意思是,在Android,WP8,Chrome iPhone模拟器下,一切都很好,甚至可以在iPad上完美运行(如果需要,可以使用Air)。

It appears to be that Google Maps API is not loaded at all. 看来根本没有加载Google Maps API。 It should be initialized after page load, and then show a map inside the page. 页面加载后应初始化它,然后在页面内部显示地图。 But there's nothing. 但是什么都没有。 Also there's no alert about querying user's location, which does happen when using an iPad. 此外,也没有关于查询用户位置的警报,这在使用iPad时会发生。

The safari on iPhone is the same version as that on my iPad, OS 7.0.4, Apple WebKit 537.51.1, Safari 9537.53. iPhone上的Safari与我的iPad,OS 7.0.4,Apple WebKit 537.51.1,Safari 9537.53的Safari版本相同。 The devices are connected to the same WiFi network. 这些设备连接到同一WiFi网络。 Due to lack of a Mac I can't use the remote debugging function right now. 由于缺少Mac,我现在无法使用远程调试功能。

Any brief ideas about what's wrong with the application? 关于应用程序出了什么问题的任何简要想法? I suspect it's inside JavaScript but I could be wrong. 我怀疑它在JavaScript内,但我可能错了。

Thanks. 谢谢。

I've found the problem and solved it. 我找到了问题并解决了。

It is because the location service is disabled for safari (by default), on iPhone. 这是因为在iPhone上,默认情况下禁用了Safari的位置服务。 However it's enabled on my iPad (not sure if it's default) so that I get different reaction from the location service API. 但是,在我的iPad上启用了此功能(不确定是否为默认设置),以便从位置服务API获得不同的响应。

I have to put an alert message for iOS users when detecting that location service is disabled. 当检测到位置服务被禁用时,我必须向iOS用户发出警报消息。 After it's enabled in the privacy settings on the device, the application works perfectly on all devices. 在设备的隐私设置中启用该功能后,该应用程序可在所有设备上完美运行。

The patch code is here for those who need. 补丁代码在这里供有需要的人使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM