bhylu.com

Advertisements

JS Location

Location describes the current page URL. Use URL to inspect its parts before considering navigation.

Where to run this

Use a local browser project for this example. It needs browser permissions, additional files, a server endpoint, or a library as described below. The restricted playground cannot provide those dependencies.

A practical example

JavaScript

const current = new URL(window.location.href);
console.log(current.pathname);
console.log(current.searchParams.get("topic"));

What happens

The local page console shows its path and optional topic parameter.