// Given a query string "?to=email&why=because&first=John&Last=smith" // $.getUrlVar("to") will return "email" (function($){ $.getUrlVar = function(key){ var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search); return result && unescape(result[1]) || ""; }; })(jQuery);