Hi @SanfordWhiteman,
Form- prefill was not working with the approach used so far. So, instead now I'm loading the form on the landing page(marketo hosted) using the form element, hiding it using css (display:none) on the page and showing it on mouseleave function. For displaying the thank you message after successful form submission, again running into the same issue where the thank you message is displaying for less than a second and then the pop-up disappears.
I have added the script below. Appreciate your help on the same
<script>
var _html = document.documentElement;
var browser_close_trigger = true;
$(_html).mouseleave(function (e) {
if (e.clientY > 20) { return }
// Trigger only once per page
if (!browser_close_trigger) { return }
browser_close_trigger = false;
var formObj=MktoForms2.getForm('2691');
MktoForms2.lightbox(formObj).show();
});
</script>
<script>
MktoForms2.whenReady(function (mktoForm) {
MktoForms2.lightbox(mktoForm, { onSuccess: showThanksEl });
function showThanksEl(vals, thankYouURL) {
var formEl = mktoForm.getFormElem()[0],
thanksEl = document.createElement("DIV");
thanksEl.innerHTML = "<div class='popUp'><h2 style='color: #fff; font-size: 38px; font-weight: 300;padding-top:10px;'>Thank you! </h2><p style='color: #fff; font-size: 16px; text-align: center;padding:20px;'>Thank you for contacting us. We'll reach out to you as soon as possible!</p></div>";
formEl.parentNode.replaceChild(thanksEl, formEl);
return false;
}
});
</script>
... View more