top of page
  • Foto do escritorFábio Henrique

Javascript - Update URL query string without refreshing the page

In order to update the query string of an URL without reloading the page, we can use the history.pushState() method.


This method receives 3 parameters (state, title, url), only the last matter for this post


const url = new URL(window.location);
url.searchParams.set('podcast', 'ninjaDevCast');
window.history.pushState({}, '', url);

Execute the code above in your browser console in order to see it working.

4.655 visualizações0 comentário

Posts recentes

Ver tudo

Opmerkingen


bottom of page