I
I
igorc752018-06-28 14:55:12
JavaScript
igorc75, 2018-06-28 14:55:12

How can I add visitor's city to text page in html?

The visitor entered the site using:

<script src="http://yastatic.net/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
  window.onload = function () {
      jQuery("#user-city").text(ymaps.geolocation.city);
  }
</script>
<script src="http://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU" type="text/javascript"></script>
Город <div id="user-city"></div>

we have defined the city, but we need the city to appear in the text of the page as well.
I understand that there is no way without reloading the page, but isn't it too many reloads?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question