"Modal On Load"
Bootstrap 4.1.1 Snippet by rafrancoso

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <div id="modalMensagem" class="modal"> <div class="modal-content"> <span class="btn-fechar">×</span> <img src="http://rsimoveismga1.tempsite.ws/images/ferias_coletivas.png"> </div> </div> <script> var modal = undefined; var fechar = undefined; window.onload = function() { modal = document.getElementById('modalMensagem'); fechar = document.getElementsByClassName("btn-fechar")[0]; modal.style.display = "block"; fechar.onclick = function() { modal.style.display = "none"; } } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } </script> </body> </html>
.modal { display: none; position: fixed; z-index: 100; padding-top: 100px; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4); } /* Modal Content */ .modal-content { background-color: #fefefe; padding: 20px; border: 1px solid #888; } /* The Close Button */ .btn-fechar { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; } .btn-fechar:hover, .btn-fechar:focus { color: #000; text-decoration: none; cursor: pointer; }

Related: See More


Questions / Comments: