Last active
April 15, 2018 11:40
-
-
Save willwm/e3929240b3413fa7703eb66f2ef5c1f1 to your computer and use it in GitHub Desktop.
Retrieve the value associated with 'key' from window.location.hash
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
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams | |
function getHashValueForKey(key) { | |
var hash = window.location.hash.substr(1); | |
var searchParams = new URLSearchParams(hash); | |
return searchParams.get(key); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
https://example.com#key1=value1&key2=value2