Answers for "javascript check get parameter"

2

javascript get parameter

let params = {};
window.location.search.slice(1).split('&').forEach(elm => {
  if (elm === '') return;
  let spl = elm.split('=');
  const d = decodeURIComponent;
  params[d(spl[0])] = (spl.length >= 2 ? d(spl[1]) : true);
});

// https://example.com/?foo=bar&best%20food=D%C3%B6ner
params['foo'] // bar
params['best food'] // Döner
Posted by: Guest on June-11-2020
0

get javascript parameter

function GetURLParameter(sParam)
{
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
            return sParameterName[1];
        }
    }
}​
Posted by: Guest on September-09-2021

Code answers related to "javascript check get parameter"

Code answers related to "Javascript"

Browse Popular Code Answers by Language