Display properties in location
<html>
<head>
<title>Location</title>
<script type = "text/javascript">
function myFunction() {
var body = document.getElementsByTagName("body")[0];
for (var prop in location) {
var elem = document.createElement("p");
var text = document.createTextNode(prop + ": " + location[prop]);
elem.appendChild(text);
body.appendChild(elem);
}
if (location.search) {
var querystring = location.search.substring(1);
var splits = querystring.split('&');
for (var i = 0; i < splits.length; i++) {
var splitpair = splits[i].split('=');
var elem = document.createElement("p");
var text = document.createTextNode(splitpair[0] + ": " + splitpair[1]);
elem.appendChild(text);
body.appendChild(elem);
}
}
}
</script>
</head>
<body onload="myFunction()">
</body>
</html>
Related examples in the same category