ภาพรวม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
YouTube Subscribe Button ให้คุณเพิ่มปุ่ม Subscribe
ลงในหน้าใดก็ได้ ปุ่มนี้จะลิงก์ไปยังช่อง YouTube เมื่อคลิกปุ่มดังกล่าว หน้าช่อง YouTube จะเปิดขึ้นในหน้าต่างใหม่เพื่อให้ผู้ใช้ยืนยันการติดตามได้
หากต้องการเพิ่มปุ่ม แอปพลิเคชันของคุณต้องโหลดไฟล์ JavaScript นี้
https://apis.google.com/js/platform.js
จากนั้นคุณจะเพิ่มปุ่มได้โดยใช้องค์ประกอบ เช่น <div>
ซึ่งตั้งค่า class
เป็น g-ytsubscribe
และใช้แอตทริบิวต์อื่นๆ เพื่อปรับแต่งปุ่ม โค้ดต่อไปนี้แสดงการผสานรวมอย่างง่ายที่แสดงปุ่ม Subscribe
สำหรับช่อง GoogleDevelopers
<script src="https://apis.google.com/js/platform.js"></script>
<div class="g-ytsubscribe" data-channel="GoogleDevelopers"></div>
นอกจากนี้ คุณยังใช้ Google+ JavaScript API เพื่อแสดงปุ่มแบบไดนามิกได้ด้วย
ตัวเลือกการกำหนดค่า
ปุ่มด้านล่างแสดงตัวเลือกเลย์เอาต์และการกำหนดค่าต่างๆ สำหรับปุ่มติดตาม ปุ่มสำหรับช่องมาตรฐานจะแสดงพร้อมและไม่มีจำนวนผู้ติดตาม
ภาษาของปุ่มจะตั้งค่าเริ่มต้นเป็นภาษาที่ผู้ใช้ตั้งค่าไว้ หรือตั้งค่าตามตำแหน่งของผู้ใช้สำหรับผู้ใช้ที่ไม่ได้เข้าสู่ระบบ
แชแนลมาตรฐาน
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-21 UTC
[null,null,["อัปเดตล่าสุด 2025-08-21 UTC"],[],[],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 | |"]]