【发布时间】:2018-05-13 02:02:42
【问题描述】:
我对 php/js 很陌生,需要一些帮助。
我的 URL 类似于 https://example.com/embed.php?ch=GOESHERE,我想让网站弄清楚 URL 在 "?ch=" 部分之后的内容并在函数中使用它。
因此,如果 URL 是“https://example.com/embed.php?ch=channel”,我希望将“频道”粘贴到函数中。
提供的javascript是(can be found here)
new Twitch.Embed("twitch-embed", {
width: 1255,
height: 500,
channel: "channel"
});
我希望 ?ch= 网址位于 channel: "channel" 当前所在的位置。
对不起,如果我没有多大意义,但我试图解释我能做的。
感谢所有帮助。
编辑 我正在使用
new URL(location.href).searchParams.get('ch')
const params = new URL(location.href).searchParams;
const ch = params.get('ch');
console.log(ch);
找到我需要的参数。现在如何将此参数粘贴到我需要它的 channel: "channel" 部分?
【问题讨论】:
-
什么是
Embed?embed的论点是什么?你对哪一部分有问题?在 javascript 中创建 URL 或在 PHP 中“读取” URL?
标签: javascript php html twitch