Last active
March 14, 2019 15:49
-
-
Save jarrettmeyer/d7ed96645c403b270609e73ec8c8f8c6 to your computer and use it in GitHub Desktop.
Getting URL query values
This file contains hidden or 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
// Get the parameters after the question mark. | |
let search = new URLSearchParams(window.location.search); | |
// Get the token and make sure it matches. | |
let token = search.get("token"); | |
if (token !== "hello-world") { | |
// The token did not match what we expected. Get rid of everything out of the body and stop the program. | |
let body = document.getElementsByTagName("body")[0]; | |
body.style.backgroundColor = "black"; | |
body.innerHTML = '<p style="color: darkred;font-size: 36px;margin: 16px;">Forbidden!</p>'; | |
throw Error("Forbidden!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment