Labels:
Get URL Parameter,
jQuery,
jQuery Code Examples,
jQuery Codes,
jQuery Tips,
QueryString,
URL Parameters
In today's post, you will see small piece of code but really effective and useful. That is how to get URL Parameters using jQuery. Now days every server language provide direct method to get the URL parameters but this is not straight forward with jQuery.
Earlier I had posted about Get Page Title and URL using jQuery, Get previous page URL using jQuery, Check for '#' hash in URL using jQuery, Style Hyperlinks based on URL extension and Use protocol less URL for referencing jQuery.
Related Post:
To implement this, I have created a function which returns value of any parameters variable.
"http://dummy.com/?technology=jquery&blog=jquerybyexample".
Feel free to contact me for any help related to jQuery, I will gladly help you.
Earlier I had posted about Get Page Title and URL using jQuery, Get previous page URL using jQuery, Check for '#' hash in URL using jQuery, Style Hyperlinks based on URL extension and Use protocol less URL for referencing jQuery.
Related Post:
- All kind of Client Side Validation using jQuery
- jQuery code to fetch thumbnail of youtube video
- Fetch Picasa or Google Plus photos using jQuery
To implement this, I have created a function which returns value of any parameters variable.
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 sParameterName[1];
}
}
}
And this is how you can use this function assuming the URL is,"http://dummy.com/?technology=jquery&blog=jquerybyexample".
var tech = GetURLParameter('technology');
var blog = GetURLParameter('blog');
So in above code variable "tech" will have "jQuery" as value and "blog" variable's will be "jquerybyexample".Feel free to contact me for any help related to jQuery, I will gladly help you.
