Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js get url variables

const postID = (new URLSearchParams(window.location.search)).get('post');
Comment

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;
};
Comment

set get variable in url

examplepage.php?var1=value&var2=value
Comment

js get variable from url

var queryDict = {};
location.search.substr(1).split("&").forEach(function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]})
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to drop collection in mongoose 
Javascript :: react text input onchange 
Javascript :: basic express graphql 
Javascript :: axios post 
Javascript :: how to convert date format using date pipe in angular 
Javascript :: javascript enum 
Javascript :: filereader check file type 
Javascript :: javascript queryselector child element 
Javascript :: jquery when iframe is loaded 
Javascript :: let in javascript 
Javascript :: datatables search not working 
Javascript :: vs code shows bodyparser deprecated 
Javascript :: webpack sass 
Javascript :: javascript change color of text input 
Javascript :: object fromentries example 
Javascript :: js float to percentage 
Javascript :: sequelize relation does not exist 
Javascript :: react app js 
Javascript :: express receive post 
Javascript :: typescript class constructor overload 
Javascript :: inheritance in es6 
Javascript :: Encountered two children with the same key, `undefined`. flatlist 
Javascript :: js host without port 
Javascript :: reset parsley validation 
Javascript :: refresh page by hand in react 
Javascript :: react bootstrap carousel caption placement top 
Javascript :: encrypt decrypt javascript 
Javascript :: json stringify close circle 
Javascript :: set timeout JS for loop 
Javascript :: how to find repeated characters in a string in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =