Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make javascript that redirects after opening a popup

Tags:

javascript

I have the following constantcontact form they provided, After they click on submit, it opens a constant contact page. However I would like that it redirect also to a page after they click on submit

<form name="ccoptin" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post" style="margin-bottom:2;">
<input type="hidden" name="llr" value="cjdttecab">
<input type="hidden" name="m" value="1101813878050">
<input type="hidden" name="p" value="oi">
<font style="font-weight: normal; font-family:Arial; font-size:12px; color:#000000;">Email:</font> <input type="text" name="ea" size="20" value="" style="font-size:10pt; border:1px solid #999999;">
<input type="submit" name="go" value="Submit" class="submit" style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:10pt;">
</form>
like image 246
Luis Valencia Avatar asked Apr 23 '26 12:04

Luis Valencia


1 Answers

Updated to 2023 code

The form generator for constantcontact is deprecated so I removed it

Give the form an ID and use setTimeout to defer the thank you to after the submit

window.addEventListener('DOMContentLoaded', () => { // when page has loaded
  document.getElementById('ccoptin').addEventListener('submit',() => setTimeout(() => {
      location.replace('thanks.html')
    }, 100)
  );
});
<form id="ccoptin" action="pageyouwantoload.php" target="_blank" method="post">
like image 61
mplungjan Avatar answered Apr 26 '26 01:04

mplungjan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!