Book a Service

').attr({ 'id': iframeId, 'src': iframeUrl, 'scrolling': 'no', 'data-no-resize': '1' }).css({ 'border': 'none', 'width': '100%' }); // Add to container $iframeContainer.html($newIframe); // Cave current ID currentIframeId = iframeId; console.log('Created new iframe:', iframeId); }, 100); // Analytics if (typeof gtag !== 'undefined') { gtag('event', 'modal_open', { 'event_category': 'Form', 'event_label': formTitle, 'iframe_id': iframeId }); } }); $(".modal-close, .modal-background").click(function() { $html.removeClass("is-clipped"); $modal.removeClass("is-active"); // Reset the iframe src to prevent loading in the background $('#universalModal').find('iframe').attr('src', ''); setTimeout(function() { // Cleanup iframe if (currentIframeId) { var $iframe = $('#' + currentIframeId); if ($iframe.length) { // Stop loading if ($iframe[0].contentWindow) { try { $iframe[0].contentWindow.stop(); } catch(e) {} } // Close resizer if (window.iFrameResize && $iframe[0].iFrameResizer) { try { $iframe[0].iFrameResizer.close(); } catch(err) {} } // Remove from DOM $iframe.remove(); } } // Reset currentIframeId = null; console.log('Modal closed and cleaned up'); }, 300); }); });