Hello, there is such a task .. in contacts for visitors to the country of Russia to show one block of contacts, for visitors from Ukraine another, for all the other two blocks simultaneously
Attacked the Internet on http://dev.maxmind.com/geoip/geoip2/javascript/
And I wrote this code:
<head> <meta charset="UTF-8"> <title>Test GeoIP</title> <script src="http://js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js" type="text/javascript"></script> <style type="text/css"> .geoip { display: none; border: 1px solid #036; padding: 10px; margin: 10px; } p { font-size: 0.8em; text-align: center; } </style> <script type="text/javascript"> function init() { var id, country = geoip2.country(); switch (country) { case 'RU': id = 'country-ru'; break; case 'UA': id = 'country-ua'; break; default: id = 'country-other'; } document.getElementById(id).style.display = 'block'; } </script> </head> <body onload="init();"> <div class="geoip" id="country-ru"> <h1>Блок для пользователей из России</h1> </div> <div class="geoip" id="country-ua"> <h1>Блок для пользователей из Украины</h1> </div> <div class="geoip" id="country-other"> <h1>Блок для пользователей из неопределенной страны</h1> </div> </body> But something does not work out at all. It turns out that I cannot pull out the "iso_code" myself ...
Maybe someone will offer some other solution?