Last active
September 24, 2015 21:49
-
-
Save sergiks/dce65d954778ffc12d15 to your computer and use it in GitHub Desktop.
GET parameters in JavaScript
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
<!DOCTYPE html> | |
<html lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="keywords" content=""> | |
<meta name="robots" content=""> | |
</head> | |
<body> | |
<script> | |
var params = window | |
.location | |
.search | |
.replace('?','') | |
.split('&') | |
.reduce( | |
function(p,e){ | |
var a = e.split('='); | |
p[ decodeURIComponent(a[0])] = decodeURIComponent(a[1]); | |
return p; | |
}, | |
{} | |
); | |
body.innerHTML = "GET data:" + params['data']; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment