How would I get the value 'b' or the value 'bluebell' from the following url:
www.example.com/en/park/wildlife-z/?item=bluebell&loc=b
I know you can use location.search
but that returns the last part of the url??
edit:
This is what I used:
function getParameterByName( name,href )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( href );
if( results == null )
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
alert(getParameterByName("param1","www.example.com/test?param1=1¶m2=2"));