Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I close the Bootstrap modal once the link has been clicked?

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?

like image 481
user1814016 Avatar asked Nov 10 '12 05:11

user1814016


People also ask

How do I close a Bootstrap modal?

Clicking on the modal “backdrop” will automatically close the modal. Bootstrap only supports one modal window at a time.

How do I close a Bootstrap modal dynamically?

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.

How do I close a specific modal?

To close the modal, simply call the handleClose() function inside the onLoginFormSubmit() function body.

How do you close modal by clicking outside of modal?

Modal Header You have two options to close this modal: Click on the "x" or click anywhere outside of the modal!


2 Answers

This works for me and doesn't require extra script tags:

<a href="http://www.example.com/" onclick="$('#myModal').modal('hide')">click</a>
like image 152
Skylar Ittner Avatar answered Sep 19 '22 10:09

Skylar Ittner


This worked for me. <a onclick="location.href='http://www.example.com/';" data-dismiss="modal">click</a>

like image 35
user11580136 Avatar answered Sep 18 '22 10:09

user11580136