// https://some.site/?id=123 var parsedUrl = new URL(window.location.href); console.log(parsedUrl.searchParams.get("id")); // 123