Is there a jquery function I can call to retrieve url paramaters.
I have been using this function below and it works fine but it breaks when the url has no parameters. I want it to return '' when there
function getUrlParameter(name)
{
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
So for www.mywebsite.com/index?var1=foo calling getUrlParameter(var1) should return foo and for www.mywebsite.com getUrlParameter(var1) should return ' '