Skip to content

Instantly share code, notes, and snippets.

@SynCap
Created January 9, 2017 14:41
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 SynCap/4e6059d9ec99348a55bf94938b2df590 to your computer and use it in GitHub Desktop.
Save SynCap/4e6059d9ec99348a55bf94938b2df590 to your computer and use it in GitHub Desktop.
Определение города посетителя. Detect user city, region, country via Yandex API & jQuery.
// Определение города посетителя
// Готовый код вставки в любое место сайта с указанием города, региона и страны.
<script src="http://yastatic.net/jquery/2.1.1/jquery.min.js"></script>
<script src="http://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () {
jQuery("#user-city").text(ymaps.geolocation.city);
jQuery("#user-region").text(ymaps.geolocation.region);
jQuery("#user-country").text(ymaps.geolocation.country);
}
</script>
<div id="user-city"></div> <div id="user-region"></div> <div id="user-country"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment