How to make an automatic closure?

<script type="text/javascript">
 var delay_popup = 5000; setTimeout("document.getElementById('overlay').style.display='block'", delay_popup);
</script>


This script opens after 5 seconds a pop window, and how to make this window close automatically after 10 seconds from opening?
June 3rd 19 at 19:30
1 answer
June 3rd 19 at 19:32
Solution
var
 overlay = document.getElementById('overlay'),
 delay_open = 5000,
 delay_close = 10000;

setTimeout(function() {
 overlay.style.display = 'block';
 setTimeout(function() {
 overlay.style.display = 'none';
 }, delay_close);
}, delay_open);

Find more questions by tags JavaScript