javascript add update query parameter to url
function update_query_parameters(key, val) {
uri = window.location.href
.replace(RegExp("([?&]"+key+"(?=[=&#]|$)[^#&]*|(?=#|$))"), "&"+key+"="+encodeURIComponent(val))
.replace(/^([^?&]+)&/, "$1?");
return uri;
}
// examples: the following may update ?page=4 in url and redirects to
window.location.href = update_query_parameters('page', '4);
Also in JavaScript:
- transfer data from one component to another angular
- prevent form submission using jquery
- comments in js
- remove axis tick ends d3
- select class with data attribute jquery
- check if localstorage key exists js
- jquery change font color
- javascript open new window
- document queryselectorall and map javacript
- how to check if window size of browser s changed javascript
- jquery clear file input
- javascript how to dynamically add asp button
- convert date to string javascript
- javascript object property + multilevel + optional chaining
- iterate through object array javascript
- convert json to 2d array
- js standard global
- firebase timestamp to date angular
- getting whole json object
- javascript randomly shuffle array
- angular flex layout
- javascript get the last element of an array
- make directive to return dropdown values angular
- Javascript check if undefined