HTML DOM Window.location property returns a Location object that contains information about the current location of the document. Window.location is read-only property.
Syntax:
var loc = window.location;
Return Value: An object containing information about the location of the document.
Example: This example shows how to get the location of the document using this property.
HTML
< h1 style = "color:green;" > Â Â Â Â neveropen </ h1 > Â Â < p > Â Â Â Â HTML window location property </ p > Â Â Â Â < button onclick = "Geeks()" > Â Â Â Â Click Here </ button > Â Â < p id = "a" ></ p > Â Â < script > Â Â Â Â var a = document.getElementById("a"); Â Â Â Â function Geeks() { Â Â Â Â Â Â Â Â a.innerHTML = window.location; Â Â Â Â Â Â Â Â console.log(window.location); Â Â Â Â } </ script > |
Output:
HTML DOM Window.location Property
Supported Browsers:
- Google Chrome
- Edge
- Firefox
- Safari
- Opera
[…] Window.location is a property that returns a Location object with information about the document’s current location. This Location object represents the location (URL) of the object it is linked to i.e. holds all the information about the current document location (host, href, port, protocol, etc.) […]