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

119
Views
windows URLSearchParams when changed

My English is not good sorry,

I do not want to let one of the URLSearchParams change.

And when the URLSearchParams is changed, returne to the my input value.

URL address : example.com/action.php?id=1&name=john&penalty=365

<input name='penalty' value='365' hidden>
<script>
 $(document).ready(function() {
  const url = window.location.href;                     
  const paramspenalt = new URLSearchParams(url.split('?')[1]);
  var penaltyvar = $('input[name=penalty]').val();
  paramspenalt.set('penalty', penaltyvar);
  const resultpenalty = paramspenalt.toString();

  window.location = 'action.php?'+resultpenalty+'';

 });
</script>

Everything is fine with this code, But the page is constantly loading.

It is very good if the page is loaded only once.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

@ksav helping me and fixed my problem from How do I modify the URL without reloading the page? :

<input name='penalty' value='365' hidden>
<script>
 $(document).ready(function() {
    const url = window.location.href;                     
    const paramspenalt = new URLSearchParams(url.split('?')[1]);
    var penaltyvar = $('input[name=penalty]').val();
    paramspenalt.set('penalty', penaltyvar);
    const resultpenalty = paramspenalt.toString();
    //****
    window.history.pushState("object or string", "Title", 'action.php?'+resultpenalty+'');
    //****
});
</script>
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!