Showing posts with label Java Script to read properties of an Object. Show all posts
Showing posts with label Java Script to read properties of an Object. Show all posts

Wednesday, 25 January 2012

Walking or Reading through the properties of Location Object of Browser

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Location, Location, Location</title>
</head>
<body>
<script type="text/javascript">
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);
}
</script>
</body>
</html>