If location is a search, display its value : location « Javascript Objects « JavaScript DHTML






If location is a search, display its value

  
<html>
<head>
    <title>Location</title>
    <script type = "text/javascript">
        function showProps() {
            var body = document.getElementsByTagName("body")[0];
            if (location.search) {
                var querystring = location.search;
                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="showProps()">
</body>
</html>

   
    
  








Related examples in the same category

1.Assign a URL to location
2.Location replace
3.Location reload
4.Display properties in location
5.location.reload(true) and history.go(0)
6.Invoking the location.replace() Method