/

HTML / CSS / JavaScript Tutorial

JavaScript Window property: location

[this page | pdf | back links]

The location property (of the JavaScript BOM window object) returns the location object for the window.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Window location: <b id="element1"></b><br>
location pathname: <b id="element2"></b><br>

<script>
var x = window.location;
document.getElementById("element1").innerHTML = x;
document.getElementById("element2").innerHTML = x.pathname;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile