-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript1.js
26 lines (21 loc) · 900 Bytes
/
script1.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
function openLightbox(imageElement) {
const lightbox = document.getElementById('lightbox');
const lightboxImage = document.getElementById('lightbox-image');
const saveButton = document.getElementById('save-button');
lightboxImage.src = imageElement.src;
lightbox.style.display = 'flex';
// Update the save button's data
saveButton.setAttribute('data-image', imageElement.src);
}
function closeLightbox() {
const lightbox = document.getElementById('lightbox');
lightbox.style.display = 'none';
}
function saveImage() {
const saveButton = document.getElementById('save-button');
const imageURL = saveButton.getAttribute('data-image');
const link = document.createElement('a');
link.href = imageURL;
link.download = imageURL.split('/').pop(); // Use the image filename as the download name
link.click();
}