Answers for "get the value from url in js"

1

get value from url

// view.jsp?id=101
let queryString = window.location.search; 
let urlParams = new URLSearchParams(queryString);
let opportunity_id = urlParams.get('id');
Posted by: Guest on September-30-2021
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

Code answers related to "Javascript"

Browse Popular Code Answers by Language