Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

After a successful form submission, how do I redirect to another page?


sssupers

Question

  • Answers 35
  • Created
  • Last Reply

Recommended Posts

This can be achieved using custom scripting.

The script waits for the input button to be clicked and sets up a listener that checks to see if the div that holds the confirmation text is visible and then sends the user to the destination page.

Add this to the code injection point for the page that holds the form:


<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>

var eventposted=0;

$(document).ready(function(){
 $('input.button').click(function() {
   window.setInterval(foo, 100);
 });
});

function foo(){
 if(($(".form-submission-text").is(':visible')) && (eventposted==0)){
   window.location = "<b>http://www.something.com/destinationpage</b>";
   eventposted=1;
 }
}

</script>




Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Link to comment

Hey All,

that's working with google form ??

so I'm trying long 'n long time figure out to redirect a G form, but nothing works for me yet.I'm using the form in static html app on facbook page, I have tried some java, iframe , html target etc.. and many possibilities found online, so I don't know where or how to fix this issue.So I'll give try Silvabokis code if works. I'm think the big problem most to be the place I'm working, so static html app on facebook is a iframe , so I'm working inside of Iframe place 'n maybe this is why any code has worked . Anybody could tell me something about it please , so I 'll appreciate, regards.

Link to comment

@silvabokis has the right code. I discovered that if you are using your form in a lightbox within an index you need to apply his code in the code injection space in the main settings or inside the site.region file if you're in developer mode.

This twist on his solution wouldn't work if you have various forms throughout the website that all need their own redirect page. I'm using this for conversion tracking and retargeted advertising, so I'm just redirecting every form submission to www.mybaseurl.com/# and inputting that as my "converted" url.

Raise Capital Faster: Reaching More Investors with the Power of Technology

Link to comment

Code(s) are working great! Thank you!

My issue is that I'd prefer it opened in another browser tab/window. Anyone know how to do that with this code?


<script type="text/javascript">
var url = "https://google.com";

// IE8 and lower fix
if (navigator.userAgent.match(/MSIE\s(?!9.0)/))
{
   var referLink = document.createElement("a");
   referLink.href = url;
   document.body.appendChild(referLink);
   referLink.click();
}

// All other browsers
else { window.location.assign(url); }

Thanks!

If needed, my site is at http://goffcreative.com (Very altered Pacific Template—I get asked a lot...)

Link to comment

Great code. However I am finding that when using the Post-Submit HTML code listed above it takes me to the new page fine. But when I hit the back button in the browser menu, it doesn't take you back to the page where you filled out the form. It's not really a big issue but I'm using the code on a newsletter form, which is on my blog. So if someone does subscribe and then chooses to go back to the blog by hitting the back button, it would be ideal if they can be sent back to the right place.

Fashion and portrait photographer

Link to comment

In my script you could increase the millisecond value in the following line:


window.setInterval(foo, 100);  

This would slow down the rate at which the script checks to see if the form submission text is visible.

However, there's then a danger that the user goes somewhere else before the redirect triggers.

Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Link to comment

Hey guys! None of the code above worked for me... after hours of wrestling with it.

But I did find a super easy solution that works great!

Put this in the form "POST-SUBMIT HTML" section under "advanced".

Then replace the URL with where you want your page redirected to.

Here is the code

<meta http-equiv="refresh" content="0; url=http://www.heike-delmore.com/thx-dont-say-the-m-word">

Link to comment

You can use Post-Submit HTML in the advanced tab of the Form block settings, just add a javascript redirect

example:


<script type="text/javascript">
   var url = "https://google.com";

   // IE8 and lower fix
   if (navigator.userAgent.match(/MSIE\s(?!9.0)/))
   {
       var referLink = document.createElement("a");
       referLink.href = url;
       document.body.appendChild(referLink);
       referLink.click();
   }

   // All other browsers
   else { window.location.assign(url); }
</script>

EDIT: This code has been updated to use window.location.assign(url) instead of window.location.replace(url), to fix an issue with the back button not working correctly. Thanks @AdySmiles and @Bernard West ! :)

Link to comment

@rubengarciam - Good question. One way to get the value of the form input would have another listener that updates JavaScript variables for each field you want to track and then test against those variables to determine the dynamic direction destination.

Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Link to comment

@Jordaniels1 – near the end there’s this line:

window.location = "http://www.something.com/destinationpage";

Just change that URL to whatever you would like.

The name is an Anglicised form of the Greek Korvetti — I like to think there’s a little bit of the ancient Hellenic drive in me.

Link to comment

Archived

This topic is now archived and is closed to further replies.

Guest
This topic is now closed to further replies.

×
×
  • Create New...