Reputation: 67
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>
Upvotes: 1
Views: 10711
Reputation: 950
Try This Code
setTimeout(function(){
$('#formSaludo').modal(); },
5000);
Hope it will be work.
Upvotes: 0
Reputation: 5715
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.
Upvotes: 0
Reputation: 166
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
Upvotes: 0
Reputation: 20199
Use setTimeout() function
$(window).load(function(){
setTimeout(function(){ $('#formSaludo').modal('show'); }, 5000);
});
Upvotes: 3