To get information about the location of the current page

To get information about the location of the current object.

 
<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
    </head> 
    <body> 
        <script> 
            document.writeln("<pre>"); 
            document.writeln("protocol: " + document.location.protocol); 
            document.writeln("host: " + document.location.host); 
            document.writeln("hostname: " + document.location.hostname); 
            document.writeln("port: " + document.location.port); 
            document.writeln("pathname: " + document.location.pathname); 
            document.writeln("search: " + document.location.search); 
            document.writeln("hash: " + document.location.hash); 
            document.write("</pre>"); 
        </script> 
    </body> 
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    DOM  

Location:
  1. The Location Object
  2. To get information about the location of the current page
  3. Location assign()
  4. Location.hash
  5. Location.hostname
  6. Location.href
  7. location.pathname
  8. location.port
  9. location.reload()
  10. location.replace()
  11. Location.search
  12. Query String Arguments