總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
YouTube Subscribe Button 可讓您在任何頁面新增 Subscribe
按鈕。這個按鈕會連結至 YouTube 頻道。點選按鈕後,YouTube 頻道頁面會在新的視窗中開啟,方便使用者確認訂閱。
如要新增按鈕,應用程式必須載入這個 JavaScript 檔案:
https://apis.google.com/js/platform.js
然後使用元素 (例如將 class
設為 g-ytsubscribe
的 <div>
),並使用其他屬性自訂按鈕,即可新增按鈕。下列程式碼顯示簡單的整合,會為 GoogleDevelopers 頻道顯示 Subscribe
按鈕。
<script src="https://apis.google.com/js/platform.js"></script>
<div class="g-ytsubscribe" data-channel="GoogleDevelopers"></div>
您也可以使用 Google+ JavaScript API 動態算繪按鈕。
設定選項
下方按鈕顯示訂閱按鈕的不同版面配置和設定選項。標準頻道的按鈕會顯示訂閱人數,也會顯示沒有訂閱人數的按鈕。
按鈕語言預設為使用者的語言設定,或根據使用者位置設定 (適用於未登入的使用者)。
標準頻道
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間:2025-08-21 (世界標準時間)。"],[],[],null,["# Overview\n\nThe YouTube Subscribe Button lets you add a `Subscribe` button to any page. The button links to a YouTube channel. Upon clicking the button, the YouTube channel page opens in a new window so that the user can confirm the subscription.\n\nTo add a button, your application needs to load this JavaScript file: \n\n```\nhttps://apis.google.com/js/platform.js\n```\n\nYou can then add a button by using an element, such as a `\u003cdiv\u003e`, that sets its `class` to `g-ytsubscribe` and uses other attributes to customize the button. The following code shows a simple integration that displays a `Subscribe` button for the GoogleDevelopers channel. \n\n```\n\u003cscript src=\"https://apis.google.com/js/platform.js\"\u003e\u003c/script\u003e\n\u003cdiv class=\"g-ytsubscribe\" data-channel=\"GoogleDevelopers\"\u003e\u003c/div\u003e\n```\n\nYou can also use the [Google+ JavaScript API](/+/web/api/javascript) to render a button dynamically.\n\nConfiguration options\n---------------------\n\nThe buttons below show different layout and configuration options for subscription buttons. Buttons for standard channels are shown with and without subscriber counts.\n\nThe button language defaults to the user's language settings or is set based on the user's location for logged-out users.\n\n### Standard channels\n\n| Buttons ||\n|-------------------------------|---|\n| Default button | |\n| Default button | |\n| Full layout (includes avatar) | |\n| Full layout (includes avatar) | |\n| Full layout, dark theme | |\n| Full layout, dark theme | |"]]