Chat | IT Hjælp til private og virksomheder





ØENS IT – Chat Support



Need Help?

Chat with us now

✓ Available 24/7 • ✓ Instant Response



if (!tidioId) { console.error('No data-tidio-id found on #tidio-config'); return; }

// 2) Dynamically load Tidio script var tidioReady = false;

function loadTidioScript() { if (window.__tidioScriptLoaded) return; window.__tidioScriptLoaded = true;

var script = document.createElement('script'); script.src = 'https://code.tidio.co/' + tidioId + '.js'; script.async = true; script.onload = function() { console.log('Tidio script loaded successfully'); }; script.onerror = function() { console.error('Failed to load Tidio script'); }; document.head.appendChild(script); }

// 3) Listen for Tidio ready event document.addEventListener('tidioChat-ready', function() { tidioReady = true; console.log('Tidio Chat is ready'); });

// 4) Open chat when button is clicked function openTidioChat() { if (window.tidioChatApi && typeof window.tidioChatApi.open === 'function') { window.tidioChatApi.open(); } else { console.warn('Tidio API not available yet'); } }

// 5) Attach click handler to button function attachButtonHandler() { var btn = document.getElementById('tidio-big-button'); if (!btn) { console.warn('Button #tidio-big-button not found'); return; }

btn.addEventListener('click', function() { if (tidioReady) { openTidioChat(); } else { // Wait for Tidio to be ready, then open document.addEventListener('tidioChat-ready', function handler() { document.removeEventListener('tidioChat-ready', handler); openTidioChat(); }); } }); }

// 6) Initialize when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { loadTidioScript(); attachButtonHandler(); }); } else { loadTidioScript(); attachButtonHandler(); } })();