/* Created by Ron Sell https://sparkmembership.com This allows you to embed a Spark Checkout Page on your own website in an iFrame. Embed this script in your website’s page before the body end tag STEPS TO USE FOR VERIFIED FACEBOOK DOMAIN: 1. In facebook business manager, start the process of verifying your domain, use the option to add TXT records in your domain’s name servers. Add the txt record to your domain’s DNS name servers. 2. Once verified by facebook, you can then use this javascript to mask your checkout page on your domain in an iframe. 3. Create a page on your website, you will use this page’s URL for advertising. We suggest creating the page “cart.html”, but you could use any page name. 4. In Spark you will find the link to your checkout page, the link starts with: https://sparkpages.io/?i=XXX, the XXX will have your checkout page’s actual ID, copy from the “?” forward, example: “?i=XXX” 5. Use this page’s URL and add the “?i=XXX” you found in step 4. 6. You can also change the title of the browser tab by adding another querystring variable by adding “&t=XXXXX” where XXXXX = the desired page name. Full example: https://yourDomainName.com/cart?i=XXX&t=XXXXX */ function getQueryString(name) { name = name.replace(/[[]/, “\[“).replace(/[]]/, “\]”); var regexS = “[\?&]” + name + “=([^&#]*)”; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return “”; else return decodeURIComponent(results[1].replace(/+/g, ” “)); } function logInstrunctions() { console.log(‘MESSAGE FROM SPARK:’); console.log(‘THIS PAGE SAYS “PAGE NOT FOUND”, here is how you remedy it.’); console.log(‘Get the Query String from Spark checkout page from the question mark forward.’); console.log(‘Example, in Spark if your checkout page URL is: https://sparkpages.io/?i=_W6v, take the last part “?i=_W6v” and add it to the URL of this page.’); console.log(‘You can also add a title to this page by adding another part to the query string. Example: “?i=_W6v&t=Enroll Now”, we added a “&t=Enroll Now”, t stands for “title”‘); } var styles = ` body{margin:0} iframe { width: 100%; height: 100vh; } `; function sparkThisPage() { var styleSheet = document.createElement(“style”); styleSheet.innerText = styles; document.head.appendChild(styleSheet); var pageTitle = getQueryString(‘t’); var ifrm = document.createElement(‘iframe’); ifrm.setAttribute(‘id’, ‘ifrm’); // assign an id document.body.innerHTML = ”; //remove current contents document.body.appendChild(ifrm); // to place at end of document ifrm.setAttribute(‘src’, ‘ https://sparkpages.io/?i=’ + i + ‘&c=’ + c); if (pageTitle.length > 0) { document.title = pageTitle; } } var i = getQueryString(“i”); //get the checkout page ID from qs var c = getQueryString(“c”); //get the contact ID from qs if (i.length === 0) { logInstrunctions(); } else { sparkThisPage(); }