Skip to main content
Colby_Dix
Level 4
Aug 26, 2014 4:27 PM UTC
Solved

form submit to _blank

So I have a landing page that's a rather simple form that i am embedding into an iframe within a wordpress post. it looks good.

When you hit 'submit' it triggers an automatic link to a pdf, which unfortunately opens up in the iframe. that doesn't look good. 

Any advice I've tried to find on this has broken links or no info on the jquery code necessary. Any help is appreciated!

Colby

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Colby_Dix
Colby_DixAccepted solution
Level 4
Aug 28, 2014 4:23 PM UTC

I figured it out, sort of. The key is to put this into the html window:

<base target="_blank" />


And then , boom, it's working in chrome at least. Not working reliably in IE...
 

ooooh shiny.

13 replies

Aug 26, 2014 4:36 PM UTC
If you change the link to download your PDF to this format, it will redirect the whole page to the PDF:

"<a href="http://example.com/example.pdf" target="_top">Download PDF</a>"

This link structure should work because "_top" target is specifying the window object of the page at the top of the frames hierarchy.
Translate
Colby_Dix
Colby_DixAuthor
Level 4
Aug 26, 2014 4:56 PM UTC
there is no href in this case, it's using the marketo form submit button to redirect to the pdf. it's not a 'link' per se. to clarify it's the 'follow up url' in the form that links to the pdf.
Translate
ooooh shiny.
Aug 26, 2014 5:03 PM UTC
Good point. Could you please post a link to the page? 

It will require a little bit of custom JavaScript. Just need to take a look at the page to see what needs to be changed. 
Translate
Colby_Dix
Colby_DixAuthor
Level 4
Aug 26, 2014 5:18 PM UTC

based on my findings here:

https://community.marketo.com/MarketoDiscussionDetail?id=90650000000PlLWAA0


I tried adding this in an html block on the landing page to no avail (the form utilized in this instance is 1090):
 

<script> 
 
  function setupFormSuccess (){
 
    var form = MktoForms2.getForm(1090);
 
    if(!form){
 
      setTimeout(setupFormSuccess, 500);
 
    }else{
 
      form.onSuccess(function (values, url){
 
        window.top.location.href = url;
 
        return false;
 
      });
 
    }
 
  }
  setupFormSuccess();
</script>

the blog post with the form exists here:

https://community.marketo.com/MarketoDiscussionDetail?id=90650000000PlLWAA0

Translate
ooooh shiny.
Aug 26, 2014 5:45 PM UTC
Almost there. Made a change that should make it work. Try the code below (you will just need to change example.com/example.pdf to the link to your pdf, but keep same structure).

Let me know if it works? 

<script> 
 
  function setupFormSuccess (){
 
    var form = MktoForms2.getForm(1090);
 
    if(!form){
 
      setTimeout(setupFormSuccess, 500);
 
    }else{
 
      form.onSuccess(function (values, url){
 
        window.top.location.href = "http://example.com/example.pdf";
 
        return false;
 
      });
 
    }
 
  }
  setupFormSuccess();
</script>

Translate
Colby_Dix
Colby_DixAuthor
Level 4
Aug 26, 2014 6:55 PM UTC
still not working... hmmm.

i also tried using only "top.location.href" , still to no avail...
Translate
ooooh shiny.
Aug 26, 2014 7:23 PM UTC
Ok. Let's keep trying. Try this:

<script> 
 
  function setupFormSuccess (){
 
    var form = MktoForms2.getForm(1090);
 
    if(!form){
 
      setTimeout(setupFormSuccess, 500);
 
    }else{
 
      form.onSuccess(function (values, followUpUrl){
 
        window.top.location.href = "http://example.com/example.pdf";
 
        return false;
 
      });
 
    }
 
  }
  setupFormSuccess();
</script>
Translate
Colby_Dix
Colby_DixAuthor
Level 4
Aug 26, 2014 7:44 PM UTC

still no. i feel like i must be missing something simple. to recap, I have a simple landing page with just a form and a small blurb of html that holds ONLY the javascript that we are trying. those are the only two elements for the LP. it uses form 1090, but the redirect after hitting submit always comes from the form settings and is not affected by the javascript at all. i know this as i set the form submit to go to an external page (google) and it goes there regardless of what's in the javascript.

does the html box need to be positioned somewhere specific for the java to take over the built in forms submit function?

Translate
ooooh shiny.
Aug 26, 2014 8:46 PM UTC
I am not sure, so I will let somebody else comment here. I'll update this comment if I can think of anything else.
Translate
Colby_Dix
Colby_DixAuthorAccepted solution
Level 4
Aug 28, 2014 4:23 PM UTC

I figured it out, sort of. The key is to put this into the html window:

<base target="_blank" />


And then , boom, it's working in chrome at least. Not working reliably in IE...
 

Translate
ooooh shiny.