Display properties in location : location « Javascript Objects « JavaScript DHTML






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

1.Assign a URL to location
2.Location replace
3.Location reload
4.If location is a search, display its value
5.location.reload(true) and history.go(0)
6.Invoking the location.replace() Method