if (document.querySelector('select[name="lang"]')) { document.querySelectorAll('select[name="lang"]').forEach(select => select.addEventListener('change', changeLang)) } function changeLang() { const val = this.value; if (window.location.href !== val) location.href = val; }