How to solve the problem with the mobile restart and localStorage?

There is a function which determines through Yandex the city and sets this default setting with the user's city
jQuery(document).ready(function () {
 ymaps.ready(function () {
 var geolocation = ymaps.geolocation;
 var city =;
 localStorage.setItem('gorod', city);

There's a problem. If you take the city with Yandex, it prescribes but in the field does not display. It appears when you restart the page.
Without the function of Yandex, the setting is set, and immediately displays

Also, there is a function to be able to provide the city.
Once selected, the value is written and the page reloads .But only in the computer version. in the Mobile to silence.
<div class="block-city">
 <div class="text-city">Change city on:</div> 
 <form id="feedbackForm2" class="form">

 <select id="fruit">
 <option value="Minsk">Minsk</option>
 <option value="Mogilev">Mogilev</option>
 <option value="Grenoble">Grenoble</option>
 <option value="Vitebsk">Vitebsk</option>
 <option value="Homel">Gomel</option>
 <option value="Brest">Brest</option>

the <script>
 document.getElementById("fruit").onchange = function() {
 localStorage.setItem('gorod', document.getElementById("fruit").value);


if (localStorage.getItem('gorod')) {
 document.getElementById("fruit").value = localStorage.getItem('gorod');

March 19th 20 at 08:28
0 answer

Find more questions by tags JavaScript