Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js append query string to url

var url = new URL("http://foo.bar/?x=1&y=2");

// If your expected result is "http://foo.bar/?x=1&y=2&x=42"
url.searchParams.append('x', 42);

// If your expected result is "http://foo.bar/?x=42&y=2"
url.searchParams.set('x', 42);
Comment

javascript add query string to url

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

PREVIOUS NEXT
Code Example
Javascript :: random choice js array 
Javascript :: map function react not appearing 
Javascript :: round a number to fixed decimals 
Javascript :: javascript clear all intervals 
Javascript :: javascript append to paragraph 
Javascript :: standalone form inside reactive form 
Javascript :: reactjs firebase where map value 
Javascript :: generate random 6 numbers in javascript 
Javascript :: javascript shuffle array 
Javascript :: js regex last occurrence 
Javascript :: jquery populate select from json 
Javascript :: javascript get bit 
Javascript :: disable mouse right click javascript 
Javascript :: how to get the min value of two variables in math 
Javascript :: orthographic camera three js 
Javascript :: how to print two arrays side by side in javascript 
Javascript :: node http post 
Javascript :: add 10 seconds to date javascript 
Javascript :: javascript get first letter of each word 
Javascript :: javascript log Time from Date 
Javascript :: hnazmul 
Javascript :: REMOVING EMPTY ARRAY INDEX 
Javascript :: convert object to json javascript 
Javascript :: javascript excel column letter to number 
Javascript :: jquery setinterval clear after first attempt 
Javascript :: fs move file 
Javascript :: 413 payload too large nodejs 
Javascript :: javascript change all anchors color 
Javascript :: javascript redirect page 
Javascript :: jq get by name 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =