Jump to content

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

Recommended Posts

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
  • 2 weeks later...
  • Replies 35
  • Views 149.8k
  • Created
  • Last Reply
  • 2 months later...

Has anything been updated on this recently? I tried to add it to the 'configure page' 'advanced' section of the page that holds the form, and instead of redirecting me to your google page once I filled out the form, it redirected me there as soon as I clicked on the page navigation!

Also - when I was trying to replace = "https://google.com"; I put = "www.whatsalreadyworking.com/thank-you"; (which is my desired landing page) and instead it came up with the URL www.whatsalreadyworking.com/discoverwww.whatsalreadyworking.com/thank-you which obviously does not exist. Thanks!

Link to comment
  • 3 weeks later...
  • 3 months later...
  • 2 weeks later...
  • 1 month later...
  • 4 months later...
  • 1 year later...

@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

Archived

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.