【发布时间】:2016-04-12 07:58:08
【问题描述】:
我有一个从 Bootstrap 示例代码中获取的简单模式。是这样的:
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<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" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
我希望能够在手机上通过返回按钮关闭模态框,因为它在移动设备上占据了整个页面,并且在右上角搜索“x”不是很方便。我查看了文档,但只有一个选项可以使用键盘上的 Escape 键关闭模式,而移动设备没有这样的解决方案。谁能帮帮我?
【问题讨论】:
-
我不了解移动开发,但是如果您可以抓住后退按钮按下事件,那么您可以触发模态关闭事件。
-
这是一个网站。我只需要这个在移动后退按钮上工作。它与按页面上的后退按钮具有相同的功能。我只是不知道如何捕捉或利用它。
标签: jquery html twitter-bootstrap