Answers for "taking variable value from url in javascript"

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
0

set get variable in url

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

Code answers related to "taking variable value from url in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language