I'm very fresh to php/js, and need some help.
My URL goes like https://example.com/embed.php?ch=GOESHERE, and I am wanting to make the site figure out what the URL says after "?ch=" part and use it in a function.
So if the URL is "https://example.com/embed.php?ch=channel" I want "channel" to be pasted in the function.
The javascript provided is (can be found here)
new Twitch.Embed("twitch-embed", {
width: 1255,
height: 500,
channel: "channel"
});
I'd like whatever the ?ch=
url is to be where the channel: "channel"
currently is.
Sorry if I'm not making much sense, but I'm trying to explain what I can.
Appreciate all help.
EDIT I am using
new URL(location.href).searchParams.get('ch')
const params = new URL(location.href).searchParams;
const ch = params.get('ch');
console.log(ch);
to find the param I need. Now how can I paste this param into the channel: "channel"
section where I need it?