document.getElementById("hidden_form").action += window.location.href.split( "?" )[1]; function submit() { document.getElementById("hidden_form").submit(); } document.getElementById("cancel").onclick = () => { let u = new URL(window.location); let uri = u.searchParams.get("redirect_uri"); if (uri === "$local") { uri = "/code"; } window.location.href = uri + "?error=access_denied&state=" + u.searchParams.get("state"); }; document.getElementById("allow").onclick = () => { submit(); };