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

86
Vistas
Perform an action after clicking on the link

I'm new to JavaScript, I need to perform an action after clicking on the link. For example, we have two pages A and B On page A, I perform a JavaScript action (filling in the text field and clicking on the button), there is a transition to page B. Here, too, you need to perform some JavaScript action, such as clicking on a link. Here is an example that only works on page A, when the transition occurs, the rest of the code seems to be erased, this is not a fact, but my guesses

document.getElementById('story').value='Титаник';
document.querySelector('body > div.wrapper > div.header > div.header44 > div.search_panel > span > form > button').click();
document.getElementsByTagName('a')[1].click();

Or another example, Follow the link and fill in the field there, which also does not work

window.location.href='http://www.ganjawars.ru/login.php'
function F() {
document.getElementsByName('login')[0].value = 'login';
document.getElementsByName('pass')[0].value = 'password';
}
 onload= F ()

How do I perform an action after clicking on a link?

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

0

Unfortunately, JavaScript does not work like this. The variables that you store on page A, will be gone, when you navigate to page B.

Possible solutions:

  • One-page website
  • jQuery post the variables to another page.
  • PHP Sessions
  • Cookies
about 4 years ago · Juan Pablo Isaza Denunciar

0

Session storage is actually the easiest solution, providing that you only want to navigate to a different page on the same website. This breaks when you close the browser or navigate to a new website.

story = document.getElementById('story').value='Титаник';
sessionStorage.setItem("story", story);
document.getElementsByTagName('a')[1].click();

and on the other page:

story = sessionStorage.getItem("story");
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