title: Redirect URL based on JSON callback data
body: <p>I tried to use JavaScript to redirect visitors by country</p>
  
  <p>The following call checks the IP of the country by visitor e.g. CN (China) and redirects it to an other web site.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script async src="https://get.geojs.io/v1/ip/country.js"&gt;&lt;/script&gt;
  
  &lt;script type="application/javascript"&gt;
    function geoip(json) {
      var countrycode.textContent = json.country;
    }
  
    if (countrycode.textContent == "CN") {
      window.location = "http://baido.com"
    }
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help?</p>