tag to automatically update all internal links with the current GET parameters. */ // Function to get all GET parameters from the current URL function getUrlParams() { const params = new URLSearchParams(window.location.search); return params.toString(); // Returns the entire query string } // Function to resolve relative URLs function resolveUrl(base, relative) { try { return new URL(relative, base).toString(); } catch (e) { //console.error('Invalid URL:', relative); return relative; // Return the original URL if it's invalid } } // Function to check if a URL is internal function isInternalUrl(url) { const currentHost = window.location.host; return url.host === currentHost; } // Function to append parameters to all internal links on the page function appendParamsToLinks(params) { if (!params) return; // If there are no parameters, do nothing const links = document.querySelectorAll('a'); // Get all links on the page links.forEach(link => { // Check if the link contains a hash fragment if (link.hash) return; // Skip links with hash fragments // Resolve the link's URL const resolvedUrl = resolveUrl(window.location.href, link.href); const url = new URL(resolvedUrl); // Check if the URL is internal if (isInternalUrl(url)) { const existingParams = url.search; if (existingParams) { // If the link already has parameters, append the new ones url.search += '&' + params; } else { // Otherwise, just add the new parameters url.search = '?' + params; } link.href = url.toString(); // Update the link's href attribute } }); } // Get the GET parameters and append them to all internal links window.addEventListener('load', function() { let d = window.location.pathname === '/' ? 750 : 250; setTimeout(function() { const getParameters = getUrlParams(); appendParamsToLinks(getParameters); // Find all iframes and append search params to matching ones const iframes = document.querySelectorAll('iframe'); iframes.forEach(iframe => { if ( iframe.id === 'sf-demo-form' || (iframe.src && iframe.src.includes('info.saffire.com')) ) { iframe.src += window.location.search; iframe.classList.add('sf-demo-form'); } }); },d); });