0
여기에 제가 가지고있는 코드가 있습니다. 이것은 작동하지만 한 번에 한 위치 만 검사합니다.내가 만든 목록의 국가를 어떻게 목록에 포함시킬 수 있습니까? (GeoIP 리디렉션)
<script>
jQuery.ajax({
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from UK, Germany, France, and Sweden.
if (location.country_code === 'UK || DE || FR || SE') {
// Redirect him to the UK Store store.
window.location.href = 'http://www.domain.co.uk';
}
}
});
</script>
그러나 그것은 작동하지 않습니다 여기에
<script>
jQuery.ajax({
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from UK.
if (location.country_code === 'UK') {
// Redirect him to the UK Store store.
window.location.href = 'http://www.domain.co.uk';
}
}
});
</script>
내가 무엇을 시도했다입니다. JavaScript에 대한 경험이별로 없기 때문에이 작업을 수행하는 방법을 100 % 확신하지는 못합니다. 나는 "국가"의 유치권을 따라 무언가로 명명 된 변수 (배열)를 만들고 var countries = ["UK", "DE", "FR", "SE"]
과 같은 국가와 동등하게 만들 수 있다고 가정하고 그 사람의 현재 위치가 배열에있는 그 나라들. 그러나, 어떻게 해야할지 모르겠다.
도움말!