pablocattaneo
6/24/2016 - 7:40 PM

Get url parameter and return it with spaces. Example https://www.domain.com/blog/?=this%20is%20a%20parameters returns "this is a parameter

Get url parameter and return it with spaces. Example https://www.domain.com/blog/?=this%20is%20a%20parameters returns "this is a parameters"

$.urlParam = function(name){
  var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
  if (results==null){
   return "";
  }
  else{
   return results[1] || 0;
  }
}

var parametro = $.urlParam('?');
parametro = decodeURIComponent(parametro);