Skip to content

Instantly share code, notes, and snippets.

@jeqo
Created June 5, 2014 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeqo/964d98ccf8dc70e5eb35 to your computer and use it in GitHub Desktop.
Save jeqo/964d98ccf8dc70e5eb35 to your computer and use it in GitHub Desktop.
JS code to print the request parameters.
<!DOCTYPE html>
<html>
<head>
<title>Start Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Hello World!</h1>
<script>
// get the current URL
var url = window.location.toString();
//get the parameters
url.match(/\?(.+)$/);
var params = RegExp.$1;
// split up the query string and store in an
// associative array
var params = params.split("&");
var queryStringList = {};
for (var i = 0; i < params.length; i++)
{
var tmp = params[i].split("=");
queryStringList[tmp[0]] = unescape(tmp[1]);
}
// print all querystring in key value pairs
for (var i in queryStringList)
document.write(i + " = " + queryStringList[i] + "<br/>");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment