--disable-web-security允许Chrome上的跨域请求的命令不再有效,我认为由于最新更新.
除了下载旧版本的chrome并禁用更新之外,还有解决方法吗?
不妨在同一个问题中提出,建议在Firefox中关闭网页安全的javascript片段对我来说无效:
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
} catch (e) {
alert("UniversalBrowserRead failed");
}
Run Code Online (Sandbox Code Playgroud)
该页面始终提醒UniversalBrowserRead failed.
不要将此问题标记为重复,stackoverflow上的任何答案都不 适合我.其中很多是针对Ionic 1或者那些答案已被弃用或者它们不适用于Android设备.
我已经在stackoverflow上看到很多关于获取设备当前位置的解决方案,但是没有解决方案似乎适用于Android.
我试过的: -
使用geolocation.getCurrentPosition(),适用于IOS和浏览器,但不适用于Android.
使用this.geolocation.watchPosition() ,适用于IOS和浏览器,但不适用于Android.
使用navigator.geolocation.getCurrentPosition(),适用于IOS和浏览器,但不适用于Android.
使用此问题提供的小提琴解决方案getCurrentPosition()和watchPosition()在不安全的起源上被弃用
无论如何,所有这些都被谷歌弃用,原因是: -
getCurrentPosition()和watchPosition()在不安全的起源上被弃用,将来会删除支持.您应该考虑将应用程序切换到安全的来源,例如HTTPS.有关详细信息,请参阅goo.gl/rStTGz.
background-geolocation plugin但是,它在Android设备上花费了近50-55秒,再次它对ios工作正常 这个问题joshmorony(https://www.joshmorony.com/adding-background-geolocation-to-an-ionic-2-application/)解决方案前景不工作为Android物理设备,但做工精细的浏览器和iOS.背景跟踪工作正常,这是第一次花费将近50秒的时间来进行拉动.
请帮我解决一下这个.我想要一种在最短时间内获得当前位置的方法.对于您的信息,我使用谷歌javascript地图sdk/api.
[阻止]访问地理位置被阻止与http://www.hnsjb.cn的不安全连接.
我应该将我的网站更改为https协议吗?
自从我使用navigator.geolocation.getCurrentPosition(如下)制作我的网站以来,控制台中出现错误。我意识到这会在未来的某个时候引起问题,而且由于我只是在玩网络开发,所以我并没有那么担心,但它现在已经完全搞砸了我的小天气应用程序(http:/ /conn3cted.uk.tn/weather.html),因为我似乎无法在 chrome 中使用此功能(它在 firefox 中有效)。我现在另外得到的错误Only secure origins are allowed. 是我能做些什么来解决这个问题吗?我真的不想无缘无故地花钱获得 HTTPS 证书。
getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS.
这是我的javascript代码:
function getLocation() {
//navigator.geolocation.getCurrentPosition(getCoor, errorCoor, {maximumAge:60000, timeout:30000, enableHighAccuracy:true});
var mobile =jQuery.browser.mobile;
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if(mobile){
watchLocation(function(coords) {
var latlon = coords.latitude + ',' + coords.longitude;
//some stuff
}, function() {
alert("error");
});
} else {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("error");
}
}
}
function watchLocation(successCallback, errorCallback) {
successCallback = successCallback || function(){};
errorCallback = errorCallback || function(){};
// Try HTML5-spec geolocation.
var geolocation = navigator.geolocation;
if (geolocation) {
// We have …Run Code Online (Sandbox Code Playgroud) geolocation ×3
android ×2
javascript ×2
html5 ×1
ionic2 ×1
ionic3 ×1
ios10 ×1
jquery ×1
security ×1