imspidey commited on
Commit
d1bd660
1 Parent(s): 1017a0a

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +26 -0
script.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Function to fetch and display images from the 'spidey' folder
2
+ function loadSpiderManImages() {
3
+ const imageGallery = document.getElementById('image-gallery');
4
+
5
+ // Replace 'spidey/' with the actual path to your 'spidey' folder
6
+ const folderPath = 'spidey/';
7
+
8
+ // Fetch a list of images in the folder
9
+ fetch(folderPath)
10
+ .then(response => response.text())
11
+ .then(data => {
12
+ const imageFilenames = data.split('\n').filter(filename => filename.trim() !== '');
13
+
14
+ // Create image elements and append them to the gallery
15
+ imageFilenames.forEach(filename => {
16
+ const img = document.createElement('img');
17
+ img.src = folderPath + filename;
18
+ img.alt = filename;
19
+ imageGallery.appendChild(img);
20
+ });
21
+ })
22
+ .catch(error => console.error('Error loading images:', error));
23
+ }
24
+
25
+ // Call the function to load Spider-Man images when the page loads
26
+ window.onload = loadSpiderManImages;