SOLVED

Re: Form submission error on Safari. Form on external CMS.

Go to solution
Tucker_Allen3
Level 2

Form submission error on Safari. Form on external CMS.

Hi,

We are using Marketo forms on our Sitecore cms. We have the forms opening a redirect in a new tab. Everything works as intended except in Safari on mobile. The form just gets stuck at "please wait" Can anyone provide any insight on our code?

Here is the page: 

https://kerry.com/applications/pharma-and-biotechnology

<script src="//app-ab33.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2050"></form>
<script>MktoForms2.loadForm("//app-ab33.marketo.com", "117-TLU-222", 2050, function(form) {
    //Add an onSuccess handler
    form.onSuccess(function(values, followUpUrl) {
        // Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
window.open(
  'https://app.salsify.com/catalogs/762cc756-2d61-48c5-8f83-f5344abcfcd8/products?filter=%3D&page=1',
  '_blank' // <- This is what makes it open in a new window.
);
 
        // Return false to prevent the submission handler continuing with its own processing
        return false;
    });
});</script> 

Thanks,


Tucker

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission error on Safari. Form on external CMS.

More like

<script src="//app-ab33.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2144"></form>
<script>
MktoForms2.loadForm("//app-ab33.marketo.com", "117-TLU-222", 2144, function(form) {
var thankyouWindow;

form.onSubmit(function(form) {
thankyouWindow = window.open("","_blank");
});

form.onSuccess(function(vals,followUpURL) {
thankyouWindow.document.location = "https://app.salsify.com/catalogs/762cc756-2d61-48c5-8f83-f5344abcfcd8/products?filter=%3D&page=1" ;
return false;
});
});
</script>

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission error on Safari. Form on external CMS.

Please highlight your code using the Advanced Editor's syntax highlighter so it's readable.

Tucker_Allen3
Level 2

Re: Form submission error on Safari. Form on external CMS.

Hi Sanford - apologies, here you are. We suspect that the error is occurring where we have _blank for opening in a new tab, but we are not sure.

Thanks for your help!

<script src="//app-ab33.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2050"></form>
<script>MktoForms2.loadForm("//app-ab33.marketo.com", "117-TLU-222", 2050, function(form) {
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
// Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
window.open(
'https://app.salsify.com/catalogs/762cc756-2d61-48c5-8f83-f5344abcfcd8/products?filter=%3D&page=1',
'_blank' // <- This is what makes it open in a new window.
);

// Return false to prevent the submission handler continuing with its own processing
return false;
});
});</script>
SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission error on Safari. Form on external CMS.

Well, you're overly optimistic about this working in other browsers. In fact it results in a popup warning, for pretty obvious reasons, in Chrome:

pastedImage_1.png

This happens because (due to longstanding browser rules) the popup must be opened in direct response to user action. In this case, that means in the onSubmit, not in the onSuccess. Then you can change the URL in the onSuccess.  I've given examples of this in the past, if you search.

Tucker_Allen3
Level 2

Re: Form submission error on Safari. Form on external CMS.

Hi Sanford,

Thanks again for looking at this. I was reviewing your other thread regarding this issue. As I'm not a developer it was a bit confusing, but I think I may have worked it out. We've updated the form based on your input. I do feel a bit more optimistic now. Can you please give me your thoughts? Same URL as above.


Thanks,

Tucker

<script src="//app-ab33.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2144"></form>
<script>MktoForms2.loadForm("//app-ab33.marketo.com", "117-TLU-222", 2144, function(form) {
//Add an onSuccess handler
form.onSubmit(function(values, followUpUrl) {
// Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
window.open(
'https://app.salsify.com/catalogs/762cc756-2d61-48c5-8f83-f5344abcfcd8/products?filter=%3D&page=1',
'_blank' // <- This is what makes it open in a new window.
);
form.onSuccess(function(vals,followUpURL) {thankyouWindow.document.location = 'https://kerry.com/products/pharma-and-biotechnology' ;
})
// Return false to prevent the submission handler continuing with its own processing
return false;
});

});</script>
SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission error on Safari. Form on external CMS.

More like

<script src="//app-ab33.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2144"></form>
<script>
MktoForms2.loadForm("//app-ab33.marketo.com", "117-TLU-222", 2144, function(form) {
var thankyouWindow;

form.onSubmit(function(form) {
thankyouWindow = window.open("","_blank");
});

form.onSuccess(function(vals,followUpURL) {
thankyouWindow.document.location = "https://app.salsify.com/catalogs/762cc756-2d61-48c5-8f83-f5344abcfcd8/products?filter=%3D&page=1" ;
return false;
});
});
</script>