{"id":8,"date":"2024-12-18T18:35:00","date_gmt":"2024-12-18T18:35:00","guid":{"rendered":"https:\/\/exfoliantesfaciales.com\/?page_id=8"},"modified":"2024-12-19T02:08:47","modified_gmt":"2024-12-19T02:08:47","slug":"iframe","status":"publish","type":"page","link":"https:\/\/exfoliantesfaciales.com\/index.php\/iframe\/","title":{"rendered":"Iframe"},"content":{"rendered":"\n<script>\n    \/\/ Function to capture all query parameters from the URL\n    function getAllQueryParameters() {\n        const urlParams = new URLSearchParams(window.location.search);\n        const params = {};\n        urlParams.forEach((value, key) => {\n            params[key] = encodeURIComponent(value); \/\/ Ensure values are safely encoded\n        });\n        return params;\n    }\n\n    \/\/ Function to build query string from parameters\n    function buildQueryString(params) {\n        return Object.keys(params)\n            .map(key => `${key}=${params[key]}`)\n            .join(\"&\");\n    }\n\n    \/\/ Function to embed the Salesforce Flow with all query parameters\n    function embedSalesforceFlow() {\n        const queryParams = getAllQueryParameters();\n        const queryString = buildQueryString(queryParams);\n\n        const flowURL = \"https:\/\/forms.caravelautism.com\/s\/\"; \/\/ URL of the flow \u2013 should be updated to the respective URL\n\n        const iframe = document.createElement(\"iframe\");\n        iframe.src = `${flowURL}?${queryString}`; \/\/ Append all query params\n        iframe.width = \"100%\";\n        iframe.height = \"2000px\"; \/\/ Adjust as needed\n        iframe.frameBorder = \"0\";\n\n        \/\/ Show spinner until iframe loads\n        const spinner = document.getElementById(\"loading-spinner\");\n        iframe.onload = () => {\n            spinner.classList.add(\"hidden\"); \/\/ Hide spinner when iframe loads\n        };\n\n        \/\/ Embed the iframe inside the div\n        document.getElementById(\"salesforce-flow-container\").appendChild(iframe);\n    }\n\n    \/\/ Listen for messages from the iframe (for redirection)\n    window.addEventListener(\"message\", function(event) {\n        \/\/ Ensure the message type is 'redirect'\n        if (event.data.type === \"redirect\" && event.data.url) {\n            \/\/ Perform the redirection\n            window.location.href = event.data.url;\n        }\n    });\n\n    \/\/ Call the function to embed the flow when the page loads\n    window.onload = embedSalesforceFlow;\n<\/script>\n\n<iframe loading=\"lazy\" src=\"https:\/\/caravelautism--staging.sandbox.my.site.com\/s\/\"  width=\"500\" height=\"1000\"\/>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/pages\/8"}],"collection":[{"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":14,"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/pages\/8\/revisions"}],"predecessor-version":[{"id":22,"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/pages\/8\/revisions\/22"}],"wp:attachment":[{"href":"https:\/\/exfoliantesfaciales.com\/index.php\/wp-json\/wp\/v2\/media?parent=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}