JavaScript | window.location and document.location Objects (original) (raw)

Last Updated : 13 May, 2020

window.location and document.location: These objects are used for getting the URL (the current or present page address) and avert browser to a new page or window. The main difference between both is their compatibility with the browsers.

All modern browsers map document.location to the window.location but you can prefer window.location for cross-browser safety.Syntax:

Example 1: This example using different properties to get different parts of URL.

javascript `

Get Different Part of a URL