javascript set query parameter
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
}
//You can reload the url like so
var newUrl=updateQueryStringParameter(window.location.href,"some_param","replaceValue");
window.history.pushState("", "Page Title Here", newUrl);
Also in JavaScript:
- router in react-router-dom
- array fill
- javascript index of biggest number
- let fruta angular
- javascript example code
- jquery set hidden field value
- download .json file
- mongoose find and update prop
- pyspark dataframe json string
- remove element from javascript array
- mysql json_extract remove quotes
- javascript object freeze
- settimeout in vuejs
- javascript is variable a string
- jquery chrome extension
- reactjs app change port
- Property 'fromPromise' does not exist on type 'typeof Observable'. rxjs 6
- how to use json stringify in javascript
- javascript on scroll change nav color
- number to array javascript
- javascript loop last index
- allow downloads from angular website
- react this.state.selectedDays.toLocaleDateString is not a function
- express ssl