I implemented onload="myFunction()"
on the body tag,
Along with this JavaScript code:
function myFunction() {
//alert("Page is loaded");
document.getElementById("test").style.display = "block";
}
function hidePopup() {
// alert("Hidden");
document.getElementById("test").style.display = "none";
}
<div id="test" style="z-index: 20000;display: none;">
<div id="popup">
<div id="close" onclick="hidePopup()">x</div>
<div id="popup_img" class="hos_modal" style="height:900px; width:900px; margin:0 auto;">
<a href="javascript:void()" target="_blank"><img src="files/image.jpg" alt="free trial" style="width: auto; height: auto;"></a>
</div>
</div>
</div>
The provided code triggers a popup when the browser is loaded. Additionally, I made use of onunload
and onmouseout
events.