Fix redirect with embed script
This commit is contained in:
parent
6428cd7d0d
commit
a84abf9f72
|
|
@ -49,8 +49,7 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
embedCode() {
|
embedCode() {
|
||||||
// eslint-disable no-useless-escape
|
// eslint-disable no-useless-escape
|
||||||
return `<script type="text/javascript" data-form-slug="${this.iframeId}" src="${appUrl("/widgets/iframe.min.js")}"><\/script>
|
return `${this.iframeCode}<script type="text/javascript" onload="initForm('${this.form.slug}')" src="${appUrl("/widgets/iframe.min.js")}"><\/script>`
|
||||||
${this.iframeCode}`
|
|
||||||
},
|
},
|
||||||
iframeCode() {
|
iframeCode() {
|
||||||
const share_url = this.extraQueryParam
|
const share_url = this.extraQueryParam
|
||||||
|
|
|
||||||
|
|
@ -473,11 +473,9 @@
|
||||||
* Starting from here is OpnForm custom code.
|
* Starting from here is OpnForm custom code.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
const formSlug = document.currentScript.getAttribute('data-form-slug')
|
function initForm(formSlug) {
|
||||||
|
if (!formSlug) {
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
return
|
||||||
if (formSlug) {
|
|
||||||
iFrameResize({log: false, checkOrigin: false}, '#' + formSlug)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('message', function (event) {
|
window.addEventListener('message', function (event) {
|
||||||
|
|
@ -485,6 +483,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
if (event.data?.type !== 'form-submitted' || event.data?.form?.slug !== formSlug) {
|
if (event.data?.type !== 'form-submitted' || event.data?.form?.slug !== formSlug) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect
|
// Redirect
|
||||||
if (event.data?.form?.redirect_target_url) {
|
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
|
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
Loading…
Reference in New Issue