Sat, July 24, 2021
 
https://devcodepro.comdevcodepro
X
Home · Latest · Trends
11

Bootstrap 4 How to open external url in modal dialog

<a href="#mymodal" data-remote="my-remote-file.php" data-toggle="modal" data-target="#mymodal">Launch demo modal</a>

<div class="modal" id="mymodal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Modal title</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                my-remote-file.php content
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div>
    </div>
</div>
<script>
$('#mymodal').on('show.bs.modal', function(e) {
    var button = $(e.relatedTarget);
    var modal = $(this);
    modal.find('.modal-body').load(button.data("remote"));
});
</script>
rated 29 times (20) (9)
comments: 0 / hits: 9128  / 2 years ago, thu, may 2, 19, 04:15:11
More From » HTML, XML
 

Comments

There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account
 
Share
Posted
cilipe
Member since May 2, 2019
Total Code Snippets: 5
Total Comments: 0
Location: n/a
cilipe snippets
2 years ago, sun, may 5, 19, 1:44:43
comments: 0 / hits: 1101
C#
2 years ago, fri, may 10, 19, 12:17:22
comments: 0 / hits: 1427
PHP
2 years ago, mon, may 13, 19, 5:24:07
comments: 0 / hits: 1050
2 years ago, thu, jul 11, 19, 5:30:34
comments: 0 / hits: 2278
CSS