pawiromitchel
1/27/2017 - 11:25 AM

JS - get the parameter from the URI

JS - get the parameter from the URI

function getUriParam(name){
    if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
      return decodeURIComponent(name[1]);
}

// usage -> url: http://localhost/index.html?id=1
var a = getUriParam('id');