【发布时间】:2015-03-20 12:34:06
【问题描述】:
我试图弄清楚如何使用地理定位将人们从 .CA 域重定向到 .US 域,并将他们保持在他们正在查看的同一页面上。 例如,如果我在社交媒体上发布如下内容:http://www.band-brand.ca/products/the-agonist-machine 单击该链接的美国居民将被重定向到主 .US 域。 我怎样才能允许他们单击该链接并将其更改为 .US 域 (http://www.band-brand.US/products/the-agonist-machine) 这是我的基本代码:
<script>
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from United States.
if (location.country_code === 'US') {
// Redirect him to the american store.
window.location.href = 'www.band-brand.us';
}
}
} );
</script>
提前感谢您的任何帮助/建议, 乔恩
【问题讨论】:
标签: jquery geolocation