Skip to content

Instantly share code, notes, and snippets.

@kaspereden
kaspereden / getSearchParameters.js
Last active January 13, 2016 12:26
Get url parameters
function get(key) {
var searchParams = {},
search = window.location.search.substring(1); // substring to remove the ?
if (search) {
search = search.split('&');
for (var i in search) {
if (search.hasOwnProperty(i) && i !== '') {
var pair = search[i].split('=');
pair[0] = decodeURIComponent(pair[0]);