Cerrar automaticamente popup: javascript
Publicado por Jp (17 intervenciones) el 27/01/2021 09:03:24
Hola ¿ sabeis de alguna funcion que permita cerrar un popup de forma automatica pasados 3segundos?
Gracias.
Gracias.
Valora esta pregunta


0






<div id="capa">...............</div>
<script>
setTimeout(() => document.getElementById("capa").style.display="none", 3000);
</script>


//document.documentElement.style.height = '100%';//document.body.style.height = '100%';//document.documentElement.style.width = '100%';//document.body.style.width = '100%';var div=document.createElement("div");
document.body.appendChild(div);
div.innerText="Contenido POPUP";
div.id = 'myDivId';
div.style.position = 'fixed';
div.style.top = '0';
div.style.left = '80%';
div.style.width = '100%';
div.style.height = '20%';
div.style.backgroundColor = 'red';
//$(document).ready(function(){// $('#open').on('click', function(){// $('#myDivId').fadeIn('slow');// //$('.popup-overlay').fadeIn('slow');// //$('.popup-overlay').height($(window).height());// return false;// });//// $('#close').on('click', function(){// $('#myDivId').fadeOut('slow');// //$('.popup-overlay').fadeOut('slow');// return false;// });//});//<div id="popup" style="display: none;">// <div class="content-popup">// <div class="close"><a href="#" id="close"><img src="images/close.png"/></a></div>// <div>// <h2>Contenido POPUP</h2>// <p>Lorem Ipsum...</p>// <div style="float:left; width:100%;">// </div>// </div>// </div>//</div>//<div class="popup-overlay"></div>//div.style.display='none';//setTimeout(function() {// $(".myDivId").fadeIn(1500);// },6000);////setTimeout(function() {// $(".myDivId").fadeOut(1500);// },3000);

var div=document.createElement("div");
document.body.appendChild(div);
div.innerText="Contenido POPUP";
div.id = 'myDivId';
div.style.position = 'fixed';
div.style.top = '0';
div.style.left = '80%';
div.style.width = '100%';
div.style.height = '20%';
div.style.backgroundColor = 'red';
setTimeout(() => div.style.display="none", 3000);





