Answers for "get variable from url in js"

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
9

js get url parameter

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const code = urlParams.get('code')
Posted by: Guest on October-18-2020
0

how to get variable from url in javascript

var getParams = function (url) {
	var params = {};
	var parser = document.createElement('a');
	parser.href = url;
	var query = parser.search.substring(1);
	var vars = query.split('&');
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split('=');
		params[pair[0]] = decodeURIComponent(pair[1]);
	}
	return params;
};
Posted by: Guest on April-03-2021
-1

js get url variables

const postID = (new URLSearchParams(window.location.search)).get('post');
Posted by: Guest on February-11-2021
0

set get variable in url

examplepage.php?var1=value&var2=value
Posted by: Guest on October-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language