From 123c3fdf7677e02d6e02a94f70fd466755150004 Mon Sep 17 00:00:00 2001 From: whatevercamps Date: Mon, 3 Feb 2020 19:38:49 -0500 Subject: [PATCH] =?UTF-8?q?Cambio=20de=20forma=20en=20el=20m=C3=A9todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/main.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/js/main.js b/js/main.js index e2f845b..d5cf0ee 100644 --- a/js/main.js +++ b/js/main.js @@ -1,28 +1,20 @@ +//Quizás intentaría mejora este cod para que se entienda mejor. Así: /** - * Método que redirije a la página en inglés + * Método que redirije a la página dado un idioma */ -function btnIngles() { +function sender(lang = "es") { setTimeout(function() { - location.href = "/en.html"; - }, 500) - ; -} -/** - * Método que redirije a la página en español - */ -function btnEspanol() { - setTimeout(function() { - location.href = "/es.html"; + location.href = `/${lang}.html`; }, 500); } function listeners(){ this.document .getElementById("btnIngles") - .addEventListener("click", btnIngles); + .addEventListener("click", () => sender("en")); this.document .getElementById("btnEspanol") - .addEventListener("click", btnEspanol); + .addEventListener("click", () => sender("es")); } -window.addEventListener("load", listeners, false); \ No newline at end of file +window.addEventListener("load", listeners, false);