Skip to content

Instantly share code, notes, and snippets.

@ambercouch
Created October 28, 2019 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambercouch/171adde179d8d2f6587f81c86e2ead6c to your computer and use it in GitHub Desktop.
Save ambercouch/171adde179d8d2f6587f81c86e2ead6c to your computer and use it in GitHub Desktop.
BBD Geo ip
<script type="text/javascript">
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from Canada.
if (location.country_code === 'CA') {
// Redirect him to the Canadian store.
window.top.location.href = 'https://bibado.ca/';
}
}
} );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment