Posted By

cerxx on 10/20/19


Tagged

js-hacks


Versions (?)

Add parameter to URL without rebooting


 / Published in: JavaScript
 

URL: https://tyapk.ru/blog/post/js-add-parameter-to-current-url-without-reload

Add parameter to URL without rebooting

  1. function updateURL() {
  2. if (history.pushState) {
  3. var baseUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
  4. var newUrl = baseUrl + '?tyapk=awesome';
  5. history.pushState(null, null, newUrl);
  6. }
  7. else {
  8. console.warn('History API not supported');
  9. }
  10. }

Report this snippet  

You need to login to post a comment.