Try it. This is pure javascript, not involved jQuery. Actually jQuery is too heavy for such work.
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 decodeURIComponent(sParameterName[1]); } } } var id = GetURLParameter('id'); var name= GetURLParameter('name');
should decodeURIComponent be used to allow the parameter value to contain any character, for example a very important equal sign = , ampersand & or question mark ? .
source share