Created
November 9, 2016 10:28
-
-
Save ktzar/21b0b7eff3240be54ca35fe09f9e1774 to your computer and use it in GitHub Desktop.
Test using anchor tag to parse URL
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
<style> | |
body { | |
font-size: 90px; | |
text-align: center; | |
color: white; | |
} | |
</style> | |
<div id="result"></div> | |
<script> | |
window.onload = function () { | |
var result = document.getElementById("result"); | |
var a = document.createElement("a"); | |
a.href = "http://www.somedomain.com/somePath?somequery=string#andAHash?hello"; | |
a.search += "&andAnotherOne"; | |
if (a.href === "http://www.somedomain.com/somePath?somequery=string&andAnotherOne#andAHash?hello") { | |
result.style.backgroundColor = "green"; | |
result.innerHTML = "CORRECT"; | |
} else { | |
result.style.backgroundColor = "red"; | |
result.innerHTML = "ERROR"; | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment