简体   繁体   中英

Bootstrap Modal Window pop-up after 5sec

Do anyone know how to make bootstrap modal window pop-up after 5sec ? I had done a Modal Window with auto pop up but I wish it's pop up delay 5 sec . can anyone help ? thanks for help . here my code .

            <div class="modal fade in" id="formSaludo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: block;">
                <div class="modal-dialog">
                     <div class="modal-content">
                          <div class="modal-header">
                              <h5><strong>給我們一個小小的贊吧~我們會帶給你更多的趣事,新聞,最新動態!您的一個贊給我們帶來無限的力量!</strong></h5>
                              <img class="img-responsive center-block " src="funnylike.jpg">
                          </div> 
                          <div class="modal-body">
                            <div class="fb-like" data-href="https://www.facebook.com/cloudsblacks" data-width="200" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>    </div> 
                            <div class="modal-footer">

                                  <a class="btn btn-link" data-dismiss="modal" style="font-size:15px;color:#808080;cursor: pointer;text-decoration: none;">已經讚了,请稍等...</a>
                          </div>  
                    </div>
                </div>
          </div>



   <!-- Modal Window -->           
<script type="text/javascript">
    $(window).load(function(){
        $('#formSaludo').modal('show');
    });
</script>   

Use setTimeout() function

$(window).load(function(){
    setTimeout(function(){ $('#formSaludo').modal('show'); }, 5000);

});

Try this:

$('#formSaludo').delay(5000).modal('show');

EDIT:

I'm not sure if the delay function will work in this case. You can always use setTimeout like others have suggested.

You will want to do something like this

var show = function(){
    $('#formSaludo').modal('show');
};

$(window).load(function(){
    var timer = window.setTimeout(show,5000);
});

https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers.setTimeout

Try This Code

setTimeout(function(){
$('#formSaludo').modal(); }, 
5000);

Hope it will be work.

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