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

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

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 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!