Fix redirect with embed script

This commit is contained in:
Julien Nahum
2024-06-27 17:06:19 +02:00
parent 6428cd7d0d
commit a84abf9f72
3 changed files with 11 additions and 9 deletions

View File

@@ -473,11 +473,9 @@
* Starting from here is OpnForm custom code.
* @type {string}
*/
const formSlug = document.currentScript.getAttribute('data-form-slug')
document.addEventListener("DOMContentLoaded", function () {
if (formSlug) {
iFrameResize({log: false, checkOrigin: false}, '#' + formSlug)
function initForm(formSlug) {
if (!formSlug) {
return
}
window.addEventListener('message', function (event) {
@@ -485,6 +483,7 @@ document.addEventListener("DOMContentLoaded", function () {
if (event.data?.type !== 'form-submitted' || event.data?.form?.slug !== formSlug) {
return
}
// Redirect
if (event.data?.form?.redirect_target_url) {
@@ -492,4 +491,8 @@ document.addEventListener("DOMContentLoaded", function () {
window.top.location.href = event.data.form.redirect_target_url
}
})
})
document.addEventListener("DOMContentLoaded", function () {
iFrameResize({log: false, checkOrigin: false}, '#form-' + formSlug)
})
}

File diff suppressed because one or more lines are too long