1
I have a Modal window that should open only once when opening the site.
Below, I have the button I use to open the Modal screen, in addition to the responsible div, I need this button to run the first time the site is opened only. How can I be doing this?
<a href="#openModal">Open Modal</a>
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<iframe width="560" height="315" src="https://www.youtube.com/embed/joNF3vycKsA?controls=0" id="iframe_callback" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<!-- Conteúdo do Modal -->
</div>
</div>
Below follows CSS code:
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 560px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }
I suggest you modify the question to facilitate understanding, so I understand you want to open the modal along with the site, for this you should use the attribute 'onload' to trigger the opening event. If you want it to appear only on the first visit, you can use cookies, the correct is to use Session, but it will not serve for this purpose.
– Macedo_Montalvão
I don’t know much about Javascript, could you give me an example? Right, that would be right.
– Agnaldo Junior
i would reply, see first these options: https://stackoverflow.com/questions/36004108/load-popup-onload | maybe I can help you.
– Macedo_Montalvão