Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Tommaso Vietina
Added: Jun 10, 2019 2:43 PM
Modified: Jun 10, 2019 2:44 PM
Views: 18
Tags: no tags
  1. let getUrlParameter = function getUrlParameter(sParam) {
  2.     let sPageURL = window.location.search.substring(1),
  3.         sURLVariables = sPageURL.split('&'),
  4.         sParameterName,
  5.         i;
  6.  
  7.     for (i = 0; i < sURLVariables.length; i++) {
  8.         sParameterName = sURLVariables[i].split('=');
  9.  
  10.         if (sParameterName[0] === sParam) {
  11.             return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
  12.         }
  13.     }
  14. };