Right now, I'm using this in a Bootstrap modal to redirect to a site:
<a href="http://www.example.com/" href="_blank">click</a>
I want the modal to be closed once the link has been clicked, so I thought adding data-dismiss="modal"
to the tag would work, however it causes the modal to close without the link being opened.
Can I combine these and make the modal close after the URL opens?
Clicking on the modal “backdrop” will automatically close the modal. Bootstrap only supports one modal window at a time.
There are few ways to close modal in Bootstrap: click on a backdrop, close icon, or close button. You can also use JavaScript hide method. Click the button to launch the modal. Then click on the backdrop, close icon or close button to close the modal.
To close the modal, simply call the handleClose() function inside the onLoginFormSubmit() function body.
Modal Header You have two options to close this modal: Click on the "x" or click anywhere outside of the modal!
This works for me and doesn't require extra script tags:
<a href="http://www.example.com/" onclick="$('#myModal').modal('hide')">click</a>
This worked for me.
<a onclick="location.href='http://www.example.com/';" data-dismiss="modal">click</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With