如何创建一个可嵌入的YouTube订阅按钮,该按钮在某人订阅后重定向?

发布于 2025-02-10 16:05:02 字数 414 浏览 2 评论 0原文

YouTube为您提供了创建可嵌入订阅按钮的能力。有什么方法可以创建这样的按钮,并将其嵌入我的网站上,但是它以使其单击“订阅”按钮后将其重定向到特定URL的方式?

这是他们提供的代码的示例。


<div class="g-ytsubscribe" data-channelid="UCAJZEjGwmVEDN2hmlT-v8Pg" data-layout="default" data-count="default"></div></center>```

I am not much of a coder so please explain in the simplest terms possible. 

Thanks in advance for any help anyone can offer.



Youtube offers you the ability to create embeddable subscribe buttons. Is there a way that I could create a button like this, and embed it on my website, but code it in such a way that it will redirect to a specific url after a person clicks the subscribe button?

Here is an example of the code they offer.


<div class="g-ytsubscribe" data-channelid="UCAJZEjGwmVEDN2hmlT-v8Pg" data-layout="default" data-count="default"></div></center>```

I am not much of a coder so please explain in the simplest terms possible. 

Thanks in advance for any help anyone can offer.



如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や三分注定 2025-02-17 16:05:02

YouTube的解决方案是不可能的 - 它们故意不包括任何重定向能力,最有可能出于安全目的。能够在订阅后有条件地重定向是一个很小但非常强大的特权。


但是,如何在新标签中打开您的频道,而不是试图重定向?设计一个外观相似的“订阅”按钮,然后将其链接到您的频道。按下后,您可以在5-10秒后通过编程方式将原始页面(在您的网站上)重定向到您想要的任何页面。

用户回到您的页面后,您打算为他们准备的任何内容都可以在那里。

这不是完美无瑕的,需要精力,但是当您想在自己的网站上做某事时,YouTube的选择受到限制。

如果您想确保仅订阅用户可以看到此页面,则可以考虑使用YouTube的API检查您的频道是否在其订阅列表中。请参阅此处有关更多信息。

This will not be possible with YouTube's solution - they intentionally do not include any redirection abilities, most likely for security purposes. Being able to conditionally redirect users after they subscribe is a small but extremely powerful privilege.


However, instead of trying to redirect after they subscribe, how about opening your channel in a new tab? Design a similar-looking 'Subscribe' button and link it to your channel. After being pressed, you could then, after 5-10 seconds, programmatically redirect the original page (on your site) to move to whatever page you wanted.

Once the user comes back to your page, whatever content you intended for them could be there.

It's not flawless and requires effort, but options with YouTube are limited when you want to do something on your own website.

If you're trying to make sure only subscribed users see this page, you could look into using YouTube's APIs for checking whether your channel is on their list of subscriptions. See here for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文