1 頁 (共 1 頁)

Bootstrap Modal iframe

發表於 : 2015-05-04 07:16:43
yehlu
http://stackoverflow.com/questions/1662 ... trap-modal

You could use the standard Bootstrap modal markup..

代碼: 選擇全部

<input id="btnHelp" type="button" class="btn" value="help">

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
            <h3>Dialog</h3>
    </div>
    <div class="modal-body">
          <iframe src="" width="100%" height="400" frameborder="0"></iframe>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal">OK</button>
    </div>
</div>
[code]
and then use modal 'show' event to dynamically set a different iframe src..

[code]
$('#helpBtn').click(function(){

    $('#myModal').on('show', function () {
        var frameSrc = "?help&section=templates"; // value can be passed from button
        $('iframe').attr("src",frameSrc);

    });
    $('#myModal').modal({show:true})
});
Demo of iFrame inside modal