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

144
Vistas
La página sigue cargando en la solicitud XML en JS, después de verificar las cookies

Soy nuevo en JS, por lo que agradecería cualquier ayuda. Creé una solicitud XML en la página que carga un video para verificar si hay cookies y luego reemplacé un elemento div "tmx" con un archivo HTML externo de mi sitio web. Sin embargo, la página sigue recargando después de obtener la solicitud XML después de inyectarla en "#tmx". Otra cosa que noté es cuando presiono el botón aceptar tnc en mi documento sin marcar la casilla de verificación, toda la página se vuelve a cargar por completo. Creo que podría ser el valor de retorno que podría estar equivocado.

 function setCookie(cname, cvalue, exdays) { if(document.getElementById('agree').checked){ const d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); let expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length,c.length); } return ""; } function checkCookieOnLoad() { if(getCookie("clicklink") === "yes") { var elem = document.getElementById("tmx"); elem.parentNode.removeChild(elem); // var elem2 = document.getElementById("ooo"); // elem2.parentNode.removeChild(elem2); var video = document.createElement('video'); video.type = "video/mp4"; video.src = ".//vid1.mp4"; video.autoplay = true; video.muted = true; video.id = "vdd1" document.body.appendChild(video); video.addEventListener("timeupdate", function(){ // current time is given in seconds if(this.currentTime >= 4.8) { // pause the playback this.pause(); this.remove(); location.replace("https://www.test.com/index.html"); } }); return true; } else { const xhr = new XMLHttpRequest(); const contianer = document.getElementById('tmx'); xhr.onload = function() { if (this.status ===200){ contianer.innerHTML = xhr.responseText; } } xhr.open('get', 'tnc.html'); xhr.send(); } }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

 setTimeout(function() { function setCookie(cname, cvalue, exdays) { if (document.getElementById('agree').checked) { const d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); let expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length, c.length); } return ""; } function checkCookieOnLoad() { if (getCookie("clicklink") === "yes") { var elem = document.getElementById("tmx"); elem.parentNode.removeChild(elem); // var elem2 = document.getElementById("ooo"); // elem2.parentNode.removeChild(elem2); var video = document.createElement('video'); video.type = "video/mp4"; video.src = ".//vid1.mp4"; video.autoplay = true; video.muted = true; video.id = "vdd1" document.body.appendChild(video); video.addEventListener("timeupdate", function() { // current time is given in seconds if (this.currentTime >= 4.8) { // pause the playback this.pause(); this.remove(); location.replace("https://www.test.com/index.html"); } }); return true; } else { const xhr = new XMLHttpRequest(); const contianer = document.getElementById('tmx'); xhr.onload = function() { if (this.status === 200) { contianer.innerHTML = xhr.responseText; } } xhr.open('get', 'tnc.html'); xhr.send(); } } }, 5000); /*This code will run after 5 seconds after the loading of HTML CSS and your JS files. Try it. Hope it helps you!!*/

about 4 years ago · Juan Pablo Isaza Denunciar
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