Created
February 1, 2012 09:41
-
-
Save vtambourine/1716180 to your computer and use it in GitHub Desktop.
Prompt URL parameters bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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