Skip to content

Instantly share code, notes, and snippets.

@vtambourine
Created January 1, 2012 17:21
Show Gist options
  • Save vtambourine/1547822 to your computer and use it in GitHub Desktop.
Save vtambourine/1547822 to your computer and use it in GitHub Desktop.
Predefined URL parameters bookmarklet
javascript: document.location.search = (function(param, value, location){
search = location.search;
if (search) {
pattern = new RegExp('([\?&]?)'+param+'=([^\?&#]*)');
clue = search.match(pattern);
if (clue) {
search = search.replace(pattern, '$1'+param+'='+value);
} else {
search += '&'+param+'='+value;
}
} else {
search = '?'+param+'='+value;
}
return search;
})('key', 'value', document.location);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment