Message entering the page

0

I wish that when someone entered my page, I would open a box , but I did not want it to be the browser default, but rather one chosen from my CSS .

Would that be possible?

Codes:

.box {
  background: white;
  border-radius: 10px;
  padding: 20px;
  }
<div class="box"></div>

I also wanted to open the box, the background would look darker around, and when it closed the normal page would be ...

    
asked by anonymous 03.06.2015 / 20:35

3 answers

1

Use the onLoad function of JS.

document.onload = function(){
    document.getElementById('box').style.display = 'block'; 
};


<div id="box"></div>

#box {
    background: #000;
    border-radius: 10px;
    padding: 20px;
    width:500px;
    height: 500px;
    position:absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;
 }
    
03.06.2015 / 20:39
1

Take a look at the sweetalert library. After you install it, just call a swal (which is the main library method) when the document is ready:

$(document).ready(function(){
    swal('Minha mensagem');
}):
    
03.06.2015 / 21:19
0

You can use Bootstrap , $.ready and $(...).modal('show'); :

$(document).ready(function(){
     $('#myModal').modal('show');
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
    
08.06.2015 / 00:08