denedim sonuç alamadım hocam
Sorununuzun nedeni, innerHTML ile yapılan manipülasyonların, DOM'daki diğer elementlerle etkileşime girerek açılır pencerenizin işlevselliğini bozması olabilir. Bunu çözmek için innerHTML yerine textContent veya insertAdjacentHTML gibi daha güvenli yöntemler kullanabilirsiniz.
Düzenlenmiş Kodlar:
1. Abone Sayısını Çeken Kod:
async function fetchSubscriberCount() {
const apiKey = 'KEY'; //
const channelId = 'Kanal İD'; //
const url = `https://www.googleapis.com/youtube/v3/channels?part=statistics&id=${channelId}&key=${apiKey}`;
try {
const response = await fetch(url);
const data = await response.json();
const subscriberCount = data.items[0].statistics.subscriberCount;
// `innerHTML` yerine `insertAdjacentHTML` kullanımı
document.getElementById('subscriberCount').insertAdjacentHTML('afterbegin', `${subscriberCount}<br><span>Kişi Abone</span>`);
} catch (error) {
console.error('Abone sayısını çekerken bir hata oluştu:', error);
document.getElementById('subscriberCount').insertAdjacentHTML('afterbegin', 'HATA<br><span>Kişi Abone</span>');
}
}2. Açılır Pencere Kodu:
Bu koda dokunmadan bırakabilirsiniz. Ancak, eğer sorun devam ederse, setTimeout veya document.addEventListener kullanımıyla ilgili olası çakışmaları incelemek gerekebilir.
Bu şekilde innerHTML yerine daha kontrollü bir yöntemle HTML eklemiş olursunuz. Eğer sorun devam ederse, tarayıcı konsolunda hata olup olmadığını kontrol ederek daha fazla detay sağlayabilirsiniz.
Not;Chatqpt den alıntıdır...