Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda