Question

This is the scenario:

  1. I have a newsletter service, that ask me for a URL on success when getting the suscriptor´s email.
  2. I´ve made a "thanks-page" in html.
  3. I´ve embed colorbox that launch a simple html part inside main html.
  4. I need to redirect to main site page after click in genuine close buttom (#cboxClose).

The script that launchs colorbox is this:

<script type="text/javascript"> 
        $(document).ready(function(){
        $.colorbox({width:"60%", inline:true, href:"#suscripcion", transition:"fade"});
        }); 
 </script>

The html which is called into colorbox modal is something like this:

<div style="display:none">
    <div id="suscripcion">
        <p><strong>Main Title</strong></p>
        <p>Thank you...</p>
        <ul>
        <li>Specs 1</li>
        <li>Specs 2</li>
        <li>Specs 3</li>
        </ul>
        <p>Good bye...</p>
    </div>                              
</div>

I don´t know how to make this, I´ve tried some examples searching "colorbox redirect...", but nothing works, so any help is really appreciated. Thanks.

Was it helpful?

Solution

You can use the click event on #cboxClose this way to redirect to your main page:

$("#cboxClose").click(function(){
   location.href = "main-page.html";
});

Applying changes to the code:

$(document).ready(function(){
  $.colorbox({width:"60%", inline:true, href:"#suscripcion", transition:"fade"});
  $("#cboxClose").click(function(){
    location.href = "main-page.html";
  });

});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top