document.addEventListener("DOMContentLoaded", function() { // Récupère l'iframe var iframe = document.getElementById("SolarSystemIframe"); if (!iframe) { console.warn("⚠️ L'iframe SolarSystemIframe est introuvable !"); return; } // Attend que l'iframe soit complètement chargée iframe.addEventListener("load", function() { var doc = iframe.contentDocument || iframe.contentWindow.document; // Récupère le bouton à l'intérieur de l'iframe var btDwarf = doc.getElementById("SolarSystemDwarf"); if (btDwarf) { btDwarf.addEventListener("click", function() { console.log("Clic sur le bouton Planètes Naines"); if (typeof OrbitalSystem.switchDispHideDwarf === "function") { OrbitalSystem.switchDispHideDwarf(); } else { console.warn("⚠️ OrbitalSystem.switchDispHideDwarf() introuvable !"); } }); console.log("✅ Bouton 'Planètes Naines' initialisé dans l'iframe"); } else { console.warn("⚠️ Bouton 'SolarSystemDwarf' introuvable dans l'iframe !"); } }); });