$(’#myModal’).modal({backdrop: ‘static’, keyboard: false});
backdrop:static时,空白处不关闭.
keyboard:false时,esc键盘不关闭.
上述代码也用于打开模态框。
或者
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog custom-dialog succ-dialog">
<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>提示信息</h4>
</div>
<div class="modal-body">
<div><img src="images/loading.gif"><p><span>投标成功!</span><img src="images/success.png"></p></div>
</div>
</div>
</div>
</div>
这里的data-backdrop="static"指定一个静态的背景,当用户点击模态框外部时不会关闭模态框。而data-keyboard是指当按下 escape 键时关闭模态框,设置为 false 时则按键无效。