The window.location object
The
window.location
object returns a Location
object with information about the current location of the document. It can be used without the window
prefix too.
The window.location.href
object returns the URL of the current page:
alert(window.location.href);