Skip to content

Instantly share code, notes, and snippets.

View varemenos's full-sized avatar

Adonis Kakoulidis varemenos

View GitHub Profile
@varemenos
varemenos / getparam.js
Created April 29, 2012 03:50 — forked from alkos333/gist:1771618
JQuery - GET URL Parameter value
// Given a query string "?to=email&why=because&first=John&Last=smith"
// getUrlVar("to") will return "email"
// getUrlVar("last") will return "smith"
// Slightly more concise and improved version based on http://www.jquery4u.com/snippets/url-parameters-jquery/
function getUrlVar(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && unescape(result[1]) || "";
}