addParamIntoUrl

PHOTO EMBED

Tue Aug 10 2021 11:22:32 GMT+0000 (Coordinated Universal Time)

Saved by @camtonguyen #javascript

function addParamIntoUrl(param, value) {
  const currentUrl = window.location.href
  const newparam = currentUrl.indexOf('?') > -1 ? `&${param}=${value}` : `?${param}=${value}`
  const newurl = currentUrl + newparam

  window.history.pushState({ path: newurl }, '', newurl)
}
content_copyCOPY