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>
Home
JavaScript Book
DOM
JavaScript Book
DOM
Location:
- The Location Object
- To get information about the location of the current page
- Location assign()
- Location.hash
- Location.hostname
- Location.href
- location.pathname
- location.port
- location.reload()
- location.replace()
- Location.search
- Query String Arguments