My current setup is similar to a lightbox feature, but I'm facing an issue where the script waits for the entire webpage to load before running. Is there a way to ensure that my script runs first without waiting for the webpage to fully load?
CSS:
#overlay {
display:none;
position:fixed;
left:0px;
top:0px;
width:100%;
height:100%;
background-image:url(gray.png);
z-index:99999;
}
#popup {
display:none;
position:fixed;
width:500px;
margin-left:400px;
margin-right:300px;
top:15%;
height:auto;
background-color:white;
z-index:100000;
border-radius: 3px;
box-shadow: 0px 0px 0px 12px rgba(0,0,0,0.3);
}
HTML:
<script type="text/javascript">
window.onload = function() {
var overlay = document.getElementById("overlay");
var popup = document.getElementById("popup");
overlay.style.display = "block";
popup.style.display = "block";
document.getElementById("CloseBtn").onclick = function(){
var overlay = document.getElementById("overlay");
var popup = document.getElementById("popup");
overlay.style.display = "none";
popup.style.display = "none";
}
};
</script>
<div id="overlay"></div>
<div id="popup">
blah blah blah