Answers for "js get current url with parameters"

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
37

javascript get current url

var currentUrl = window.location.href;
Posted by: Guest on July-22-2019
6

get params js

// www.example.com/users?token=12345

let params = (new URL(document.location)).searchParams;
let token = params.get("token");
// 12345
Posted by: Guest on July-17-2020
0

get url params with js

const queryString = window.location.search;

const urlParams = new URLSearchParams(queryString);

const page_type = urlParams.get('page_type')

console.log(page_type);
Posted by: Guest on August-08-2021
2

javascript get parameter

let params = {};
window.location.search.slice(1).split('&').forEach(elm => {
  if (elm === '') return;
  let spl = elm.split('=');
  const d = decodeURIComponent;
  params[d(spl[0])] = (spl.length >= 2 ? d(spl[1]) : true);
});

// https://example.com/?foo=bar&best%20food=D%C3%B6ner
params['foo'] // bar
params['best food'] // Döner
Posted by: Guest on June-11-2020

Code answers related to "js get current url with parameters"

Code answers related to "Javascript"

Browse Popular Code Answers by Language