【发布时间】:2015-11-12 02:13:48
【问题描述】:
我的引导模式正在尝试启动嵌入式谷歌地图 iframe。在页眉中我有一个关闭按钮,在页脚中我有另一个关闭按钮。
问题是页眉和页脚没有正确附加到包含地图的模态体。我什至通过删除 iframe 来尝试它。 iframe 现在是问题,因为即使是白色背景且正文中没有任何内容,它仍然无法正确排列。
这是我的代码:
HTML:
<div id="ModalCabotoMap" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
</div>
<div class="modal-body">
<iframe id="CabotoMap" src="https://www.google.com/maps/..."></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
这里是 JS:
$(document).ready(function(){
/* Get iframe src attribute value i.e. YouTube video url
and store it in a variable */
var url = $("#CabotoMap").attr('src');
/* Assign the initially stored url back to the iframe src
attribute when modal is displayed again */
$("#ModalCabotoMap").on('show.bs.modal', function(){
$("#CabotoMap").attr('src', url);
});
$('#ModalCabotoMap').on('shown', function () {
google.maps.event.trigger(map, "resize");
});
});
【问题讨论】:
-
我认为您在模态标题 div 之后关闭了模态内容 div。尝试在 modal-content 中包含模态头部、正文和页脚。
-
@RossiRobinsion 你是真正的 MVP!你是对的,我过早地关闭了模态体 div。现在看起来很完美。请将您的回复作为答案发布,我会这样标记。
-
会发生这种情况,但我们会学习。很高兴您获得了成功。
标签: javascript jquery html twitter-bootstrap bootstrap-modal