Forked from dylanjhunt/Display a popup on IP in certain country
Created
April 20, 2018 10:53
-
-
Save dav11d/d00e3bd901e4282121fb9fc86922f1bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
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') { | |
// Tell him about the Canadian store. | |
jQuery.fancybox.open(jQuery('#message')); | |
} | |
} | |
} ); | |
</script> | |
<div style="display:none;"> | |
<div id="message" style="padding:30px;"> | |
<h1>Hello!</h1> | |
<p>You are in Canada, and we have a Canadian website <a href="https://dylanjh.com">here</a>.</p> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment