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

165
Views
Cómo actualizar una página con jQuery pasando un parámetro a la URL

Estoy actualizando mi página usando jQuery:

 location.reload();

Esto funciona muy bien, pero quiero actualizar la misma página pasando un parámetro a la URL.

¿Cómo puedo hacer esto usando jQuery?

Ex:

Si mi URL es www.myweb.com , quiero actualizar esto pasando un parámetro como este

 www.myweb.com?single

Gracias

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Debería poder lograr esto usando location.href

 if(window.location.hostname == "www.myweb.com") window.location.href += "?single";
over 4 years ago · Santiago Trujillo Report

0

Usaría REGEX con .replace así:

 window.location.href = window.location.href.replace( /[\?#].*|$/, "?single" );
over 4 years ago · Santiago Trujillo Report

0

Puede usar Javascript URLSearchParams .

 var url = new URL(window.location.href); url.searchParams.set('single',''); window.location.href = url.href;

[ACTUALIZAR]: si necesita soporte para IE, consulte este hilo:

SCRIPT5009: 'URLSearchParams' no está definido en IE 11

Gracias @john-m por hablar sobre el soporte de IE

over 4 years ago · Santiago Trujillo 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!