点击关闭时,Bootstrap模态弹出窗口打开

时间:2017-08-10 11:49:14

标签: javascript twitter-bootstrap

您好我已经创建了用于询问客户反馈的bootstrap模型。此模型将显示用户何时尝试关闭点击或浏览器。帮助我。

型号:

<div id="myModal" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
          </div>
          <div class="modal-body">
            <div class="popupBG1">

                <div class="popupCTARow">
                    <div class="popupCTA1">
                        <a href="javascript:void(0);">Ok</a>
                    </div>
                    <div class="popupCTA2">
                        <a href="javascript:void(0);">Cancel</a>
                    </div>
                </div>
           </div>
    </div>  

Javascript:

<script type="text/javascript">
        $(document).ready(function() {
            $("#myModal1").modal('show');
        });    
</script>

1 个答案:

答案 0 :(得分:2)

用户试图离开时,您无法显示引导模式,但如果您想要的话,则可以显示提示:

window.onbeforeunload = function(){
  return 'Are you sure you want to leave?';
};

https://codepen.io/kastriotcunaku/pen/xLrVRb