简体   繁体   中英

Bootstrap 3.3.1 modal popup close from inside iframe

I have an iframe through jQuery and bootstrap, and I need to add a Close button inside the iframe page itself, not from the popup window that opens.

I tried adding <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> in the html popup page, but it does nothing.

Here is the current code with the outer close button, and an example page link of bbc.com:

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://bootstrapdocs.com/v3.3.1/docs/dist/js/bootstrap.min.js"></script> <link href="https://bootstrapdocs.com/v3.3.1/docs/dist/css/bootstrap.min.css" rel="stylesheet"/> <button class="btn btn-primary" data-toggle="modal" data-target="#myModal">Popup page</button> <!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="padding:0px"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> </div> <div class="modal-body"> <iframe src="https://bbc.com" style="width:500px; height:500px; max-width:100%; max-height:100%" frameborder="0" allowtransparency="true"></iframe> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> 

I found this post but not sure how to implement it in the current case.

你可以添加这样的按钮,并为iframe提供一些id'blackout'。

<button type="button" class="btn btn-default" onclick="window.jQuery('#blackout').toggle('slow');">Open/Close</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM