Redirect parent after close of form submission lightbox

  • 7 October 2016
  • 5 replies
  • 35 views

Hi,

I’m trying to send the user to my actual website automatically after receiving the success message from completing a form submission.

When the form is complete the lightbox pops up, but I can’t manage to redirect them after they close the lightbox.

I’ve tried this:

var closelightbox = document.getElementById('element-id');
closelightbox.onclick = redirectPage;

function redirectPage() {
	window.top.location.href = "https://www.example.com"; 
	return false;	
}

For element-id, I have used:

ubpoverlay-overlay
ubpoverlay-close

It works on elements within the lightbox but not anything outside of the lightbox. Essentially I want to click anywhere on the page and be redirected.

And just body wide:

$(document.body).click(function() {
window.top.location.href = "https://www.example.com"; 
});

Any ideas?

Thanks


5 replies

Userlevel 6
Badge +1

Hey @Savage I believe this is what you’re looking for http://jsfiddle.net/73hutxe3/ let me know if that works for you.

Hi @digibomb,

Thanks for your reply. I don’t think Unbounce uses featherlight?

It has it’s own script here: http://builder-assets.unbounce.com/published/jquery.ubpoverlay-d9900bb.z.js

But I can’t work out how to edit the ‘onClosed’ event, similar to what your answer has suggested.

Cheers,

Userlevel 7
Badge +3

Hi @Savage,

Here is an older community thread related to your question.

You can find some example scripts there and adjust based on your particular case.

Hi @Hristian

Perfect, thanks very much.

Userlevel 6
Badge +1

Hey @Savage you are correct, was just an example 🙂 But, I see @Hristian has provided and answer as well, I hope this has done the job.

Reply