Skip to content

Instantly share code, notes, and snippets.

@vtambourine
Created February 1, 2012 09:41
Show Gist options
  • Save vtambourine/1716180 to your computer and use it in GitHub Desktop.
Save vtambourine/1716180 to your computer and use it in GitHub Desktop.
Prompt 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', prompt('value of key is:'), document.location);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment