Answers for "javascript get current url parameter value by name"

29

get parameter from the actual url javascript

// https://testsite.com/users?page=10&pagesize=25&order=asc
const urlParams = new URLSearchParams(window.location.search);
const pageSize = urlParams.get('pageSize');
Posted by: Guest on December-04-2020
2

js check for url parameter

const params = new URLSearchParams(window.location.search);

// Check if we have the param
if (params.has("myParam")) {
  console.log("Yep!  We have it.  Value is: " + params.get("myParam"));
} else {
  console.log("The param myParam is not present.");
}
Posted by: Guest on May-08-2021

Code answers related to "javascript get current url parameter value by name"

Code answers related to "Javascript"

Browse Popular Code Answers by Language