Created
January 9, 2017 14:41
-
-
Save SynCap/4e6059d9ec99348a55bf94938b2df590 to your computer and use it in GitHub Desktop.
Определение города посетителя. Detect user city, region, country via Yandex API & jQuery.
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 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