Skip to content

Home

Window.location Cheat Sheet

The window.location object is particularly useful when working with a page's URL information. Let's take a look at an example of a URL and what each property of the window.location object represents.

const url = 'https://dev.30secondsofcode.org:8000/c/js?page=2&sort=asc#search';

Provided the above URL, here's a quick reference for the properties window.location object:

window.location.protocol

window.location.hostname

window.location.port

window.location.host

window.location.origin

window.location.pathname

window.location.search

window.location.hash

window.location.href

More like this

Start typing a keyphrase to see matching snippets.