Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!