Inserting a Marketo form in Adobe Edge Animate?

Connie_Tran1
Level 1

Inserting a Marketo form in Adobe Edge Animate?

I created an animation within Edge Animate that calls a form at the end of it for a user to submit their info. I've had success calling an iFrame with the form in it, but that doesn't work with Marketo landing pages (I assume it's because Marketo landing pages aren't https and my domain demands it). I want to use the embed script that Marketo provides to avoid the https/http problem, but I'm not sure how to implement it.

I tried adding this code in compositionReady:

sym.$("MarketoFormField").html("<script src='//app-sj19.marketo.com/js/forms2/js/forms2.min.js'></script><form id='mktoForm_1030'></form><script>MktoForms2.loadForm('//app-sj19.marketo.com', '903-ASE-543', 1030);</script>");

but it doesn't work (note that using an iFrame with an https form DOES work).

I am also a self-taught coding person so maybe I got this all wrong.

Any ideas?

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Inserting a Marketo form in Adobe Edge Animate?

Thread should be moved to Products​. Remember, the "Community" space is for website feedback (and yes, that's confusing).

Although you should post your example URL, I assume you have a classic asynchronous script loading problem.

Unless you make MktoForms2.loadForm depend on the external script forms2.min.js being loaded first, this won't work.  Script-injecting other remote scripts (that's what's happening when you insert HTML with a <script> tag in it after the page's DOM has initially loaded) always means the remote script is loaded asynchronously.  So when MktoForms2.loadForm attempts to run, it fails because MktoForms2 doesn't exist yet.

I would instead have the <script> that loads forms2.min.js enabled all the time (in the <head> of your page).  Then you just run MktoForms2.loadForm when you need it. There's no need for a $() wrapper here.