Bootstrap模型在点击按钮时显示远程URL,但我们想确保它与父页面一起加载
答案 0 :(得分:0)
您可以使用 IFrame ,一旦设置src
,就会开始加载。
其他方法是使用jQuery Ajax,如jQuery.load
。
(function(){
// Load remote content
// Remote URL
var url = 'https://loremflickr.com/450/220';
// Set source and it starts loading
document.getElementById('remotePage').src = url;
})();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<iframe id="remotePage" frameborder="0" height="250" width="100%"></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 -->
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
View Remote Content
</button>