Answers for "retrieve variables in the url 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 "retrieve variables in the url javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language