1// www.example.com/users?token=12345
2
3let params = (new URL(document.location)).searchParams;
4let token = params.get("token");
5// 12345
1let params = {};
2window.location.search.slice(1).split('&').forEach(elm => {
3 if (elm === '') return;
4 let spl = elm.split('=');
5 const d = decodeURIComponent;
6 params[d(spl[0])] = (spl.length >= 2 ? d(spl[1]) : true);
7});
8
9// https://example.com/?foo=bar&best%20food=D%C3%B6ner
10params['foo'] // bar
11params['best food'] // Döner
1function GetURLParameter(sParam)
2{
3 var sPageURL = window.location.search.substring(1);
4 var sURLVariables = sPageURL.split('&');
5 for (var i = 0; i < sURLVariables.length; i++)
6 {
7 var sParameterName = sURLVariables[i].split('=');
8 if (sParameterName[0] == sParam)
9 {
10 return sParameterName[1];
11 }
12 }
13}
14