Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
Get google translate language plain javascript on select from dropdown

I want to get the selected language from an embedded Google translate script in a dynamic php website.

I have inserted in the head

<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'el', includedLanguages: "en,el" 
 }, 'google_translate_element');
 }
 </script>
 <script type="text/javascript" src="//translate.google.com/translate_a/element.js? 
 cb=googleTranslateElementInit"></script>

and in body:

<div style="text-align:center!important;" id="google_translate_element"></div>

and translate dropdown appears ok and does the job ok.

I want to detect the selection of the language, so I run some script depending on the selection.

So far the javascript that is executing correctly is:

<script type="text/javascript">
window.setInterval(function(){
 lang = $("select.goog-te-combo option:selected").text();
alert(lang);
 },7000);
 </script>

that shows an alert window every 7 sec with the selected language text.

How do I change the above script so that is executed only on dropdown selection change?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda