简体   繁体   中英

Bootstrap modal popup open when tap close

Hi i have created bootstrap model for asking customer feedback. This model will show when user try to close tap or browser. Help me.

Model :

<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>

You can't show bootstrap modal when users try to leave, but you can show prompt, if that's what you want:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM