I prefer my popup to have a dark or blurred background when active. The popup itself should remain the same, with only the background being darkened. I would like a dark layer overlaying the entire page. This script should be compatible with any website where it is included.
The code must be written in Javascript. When the popup is closed, the page should return to its normal state as per the provided code.
window.onload = addElement;
function addElement() {
// create a new div element
// and give it popup content
var newDiv = document.createElement("div");
var texts = 'erd';
newDiv.innerHTML += '<div id="popup" style=" position: absolute;top: 5%;width: 800px;height: 200px;margin: auto;z-index: 99999;display: block;left:25%;background-color: #fff; border: 1px solid #ddd; border-radius: 5px; box-shadow: 0 1px 6px 4px #000; overflow: hidden; padding: 10px;"><div class="popup_body" style=" height: 160px;">' + texts + '</div><button style="padding: 10px;" class="close_button"onClick="closePopup()">Close</button><button style="padding: 10px;" class="close_button"onClick="showInfo()">More Info</button></div>';
// add the newly created element and its content into the DOM
var currentDiv = document.getElementById("main_container");
document.body.insertBefore(newDiv, currentDiv);
// open popup onload
openPopup();
}
function openPopup() {
var el = document.getElementById('popup');
el.style.display = 'block';
var BG = document.createElement("div");
BG.style.background-color = 'black'; // Change this line
BG.style.width = '100%';
BG.style.height = '100%';
}
function showInfo() {
window.location.href = '../testing/info.php';
}
function closePopup() {
var el = document.getElementById('popup');
el.style.display = 'none';
}
teefsffstfssgrhhsggsrhservgssfvrhthtrdg rthsgssdsgsssssgegdgssstyygghdeeffsdfsfsdgtrhhfhtrrthsgssdsgsnjissgegdgss
sdrfdsdeeffsdfsfsdgtrhhfhtrrthsgssd
sgsgfksgegdgssjhsssdeeffsdfsfsdgtrhhfhtrrthsgssdsgsstrsgegdgssuiopssdeeffsdfsfsdgtrhhfhtrrthsgssdsgsesrrressgegdgssslkkjsdeeffsdfsfsdgtrhhfhtrvvvtkiyoyuirt