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

238
Vistas
Script to automate the passing credentials to next page

I have one URL which asks me to " click here to login" then the next page loads. once the next page loads I need to pass the credential. tried below script but didn't work

document.getElementsByClassName('click_hereTo_login')[0].click();

$( document ).ready(function() 
{ if document.location.href=="https://example.com/secondpage"
then {
  document.getElementById('id').value="12322";
document.getElementById('password').value="4444";
document.getElementsByClassName('login')[0].click();
}})

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First of all your if is not written correctly. It should be:

if (document.location.href=="https://example.com/secondpage"){
    document.getElementById('id').value="12322";
    document.getElementById('password').value="4444";
    document.getElementsByClassName('login')[0].click();
}

The another problem here is, that your script runs from scratch on both pages. If you want to pass data from page to page without backend, you can use either query string or localstorage to store the data somewhere and then access it from another page.

let id = localStorage.getItem('id');

// get the input element 
let idInput = document.getElementById('id');

// check if we are one second page
if(idInput) {
    document.getElementById('id').value = id;
}

// Save id on login click
document.querySelector('.login').addEventListener('click', () => {
    localStorage.setItem('id', 1234);
});
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