<script type="text/javascript">
<!--
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
// -->
</script>
The way that the function is used is fairly simple. Let's say you have the following URL:
http://www.foo.com/index.html?bob=123&frank=321&tom=213#top
You want to get the value from the frank parameter so you call the javascript function as follows:
var frank_param = gup( 'frank' );
The parameter output for frank is 321.
Taken From : http://www.netlobo.com/url_query_string_javascript.html
No comments:
Post a Comment