In raw Javascript, how would one go about checking that a specific hash tag exists in a url, then grab the value?
Example: http://www.example.com/index.html#hashtag1=value1&#hashtag2=value2
I want to be able to grab the value of either hashtag1 or hashtag2.
Using it:
Check if a “hash key” is present:
Get the value for a hash key:
Set the value for a hash key, and update the URL hash:
Remove a hash key from the URL:
Reload the hash into the local object:
Push the current key value set to the URL hash:
Note that when a key does not exist and you try to
getit, it will returnedundefined. However, a key could exist with no value — for example#key=val&novaluewhere novalue is a key with no value. If you doHashSearch.get("novalue")it would also returnundefined. In which case, you should useHashSearch.keyExists("novalue")to verify that it is indeed a key.