Launch Bootstrap Modal on Page Load

Oftentimes we are caught in the web of showing up an update, advertising a product, and even passing out an important update on our website and/or a webpage upon visit.

Below is an example of basic HTML and Javascript codes that can get the job done with no hassle.

JS

<script type="text/javascript">
    $(window).on('load', function() {
        $('#myModal').modal('show');
    });
</script>

HTML

<div class="modal hide fade" id="myModal">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>
        <h3>Modal header</h3>
    </div>
    <div class="modal-body">
        <p>One fine body…</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
    </div>
</div>

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *