1const urlParams = new URLSearchParams(window.location.search);
2const myParam = urlParams.get('myParam');
3
1const getParameters = (URL) => {
2 URL = JSON.parse('{"' + decodeURI(URL.split("?")[1]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') +'"}');
3 return JSON.stringify(URL);
4};
5
6getParameters(window.location)
7// Result: { search : "easy", page : 3 }
8
1function getQueryVariable(variable)
2{
3 var query = window.location.search.substring(1);
4 var vars = query.split("&");
5 for (var i=0;i<vars.length;i++) {
6 var pair = vars[i].split("=");
7 if(pair[0] == variable){return pair[1];}
8 }
9 return(false);
10}