View Single Post
Old 11-24-2012, 12:16 AM   PM User | #1
Mooseman
Regular Coder

 
Mooseman's Avatar
 
Join Date: Sep 2010
Posts: 118
Thanks: 7
Thanked 3 Times in 3 Posts
Mooseman is an unknown quantity at this point
jQuery.url - easy URL parameter retrieval

This is a simple jQuery plugin to pull parameters from a URL; if not available, will return 'undefined'

For example, if the page is http://example.com/index.html?foo=bar, $.url("foo"); will return bar

Code:
jQuery.url = function(paramName) {
	var results = new RegExp("[\\?&]"+paramName.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]")+"=([^&#]*)").exec( window.location.href );
	if(results == null){return "undefined";} else{return results[1];}
};
Not sure how useful this really is, but I hope it helps somebody.
Mooseman is offline   Reply With Quote