【发布时间】:2017-10-23 19:06:41
【问题描述】:
我的地理位置响应 country_name 在 Chrome 和 Firefox 中有效,但在 Safari 中不可用。我该如何解决这个问题?
Javascript:
$.get("http://freegeoip.net/json/", function (response) {
$("#ip").html("IP: " + response.ip);
$("#country_code").html(response.country_code);
if(response.country_code=='NL'||response.country_code=='US'){
document.getElementById(response.country_code).style.display = "block";
}
}, "jsonp");
HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="NL">THE NL</div>
<div id="US">THE US</div>
CSS:
#NL { display:none;}
#US { display:none;}
【问题讨论】:
-
你有 safari 的广告拦截插件吗?
-
没有有效的广告拦截器。但是,如果我检查该元素,Safari 会给出以下错误:[警告] [阻止] 该页面不允许运行来自 freegeoip.net/json 的不安全内容
标签: javascript jquery geolocation country-codes