-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
32 lines (27 loc) · 978 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
document.addEventListener('DOMContentLoaded', function() {
const popup = document.getElementById('popup');
const closeBtn = document.getElementById('close-btn');
const body = document.body;
// Function to show the popup and disable scrolling
function showPopup() {
popup.style.display = 'flex';
body.style.overflow = 'hidden'; // Disable scrolling
}
// Function to hide the popup and enable scrolling
function hidePopup() {
popup.style.display = 'none';
body.style.overflow = ''; // Enable scrolling
}
// Show the popup on page load
showPopup();
// Close the popup when the close button is clicked
closeBtn.addEventListener('click', function() {
hidePopup();
});
// Optionally close the popup when clicking outside the popup content
window.addEventListener('click', function(event) {
if (event.target === popup) {
hidePopup();
}
});
});