I have a link that redirects to a product page by it's id, but I want to show a modal before it redirects. I would like the user to confirm that he has read it, and only redirect if he confirms, otherwise he would stay at the same page. (I apologize for the bad English)
You may find this example useful: http://www.bootply.com/63844
$('#btnYes').click(function() {
// handle redirect here
var link = $('#myModal').data('link');
location.href = link;
$('#myModal').modal('hide');
});
It uses a click handler on the link to trigger the modal, and then does the redirection once a button (#btnYes
) inside the modal is clicked. The redirect link is defined using a data attribute on the link.
First, link to the modal, then link to the product page from the modal, if a certain button is clicked.