JavaScript: Get Query String Values In Javascript

2/8/2015 6:55:38 PM

Return the query string GET values in a url.

<script type="text/javascript">

//get query string value
function get_query_string_value(key)
{
	var fullUrl = window.location.search.substring(1);
	
	var valuePairs = fullUrl.split("&");
	for (x = 0; x < valuePairs.length; x++)
	{
		var valuePair = valuePairs[x].split("=");
		if (valuePair.length == 2)
		{
			if (valuePair[0].toLowerCase() == key.toLowerCase())
			{
				return valuePair[1];
			}
		}
	}

	return "";
}

</script>