Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: setimeout 
Javascript :: for of javascript 
Javascript :: javascript full date as string 
Javascript :: toLocalString 
Javascript :: Class constructor cannot be invoked without new 
Javascript :: js sort by two numeric fields 
Javascript :: expo modal 
Javascript :: angular tab change smooth transition 
Javascript :: javascript html video seek to time 
Javascript :: try catch javascript 
Javascript :: jquery find input and select 
Javascript :: npm ERR! Error: connect ECONNREFUSED 
Javascript :: jquery onclick click 
Javascript :: javascript filter array match includes exact 
Javascript :: ios/main.jsbundle no such file or directory react native 
Javascript :: upgrade or update nodejs 
Javascript :: svg css viewbox 
Javascript :: js copy text 
Javascript :: for in js 
Javascript :: null + undefined 
Javascript :: insert array as string google app scripts 
Javascript :: foeach in js 
Javascript :: set exit node tor 
Javascript :: react icon import 
Javascript :: javascript telegram bot 
Javascript :: date picker javascript not working 
Javascript :: nestjs custom error class validator 
Javascript :: Discord.js Get A Bot To Join A Music Chanel 
Javascript :: js match regex 
Javascript :: using fb login with angular app 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =